Skip to content

[BUG] preinstall script with npx does not work with --package-lock-only #4595

Description

@McFoggy

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

A preinstall script using npx fails when master command npm install --package-lock-only is fired.
It works when master command is npm install

Behaviors differs between npm 6.x & npm 8.x but none are correct.

Expected Behavior

npm install --package-lock-only shoud be successfull and should execute correctly the presinstall script.

Steps To Reproduce

  • mkdir reproducer && cd reproducer
  • nvm use 16
    • at the time of filling bug it installs : node v16.14.0 (npm v8.3.1)
  • rm -rf ~/.npm/_npx using a clean npx cache
  • using the following package
cat <<EOF > package.json
{
    "name": "issue-only-allow-npx-package-lock-only",
    "version": "1.0.0",
    "description": "'npm install' works, 'npm install --package-lock-only' fails",
    "scripts": {
        "preinstall": "npm_config_yes=true npx only-allow npm"
    }
}
EOF
  • npm install --package-lock-only fails
npm install --package-lock-only                                                      

> [email protected] preinstall
> npm_config_yes=true npx only-allow npm

sh: 1: only-allow: not found
npm ERR! code 127
npm ERR! path /home/m.brouillard/projects/lectra/ui/issue-only-allow-npx-only-allow
npm ERR! command failed
npm ERR! command sh -c npm_config_yes=true npx only-allow npm

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/m.brouillard/.npm/_logs/2022-03-22T08_24_16_404Z-debug-0.log

Environment

  • npm: 8.3.1
  • Node.js: 16.14
  • OS Name: Ubuntu 18.04
  • System Model Name: HP Probook

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingPriority 2secondary priority issueRelease 8.xwork is associated with a specific npm 8 release

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions