Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
2 tasks done
McFoggy opened this issue Mar 22, 2022 · 1 comment · Fixed by #4843
Closed
2 tasks done

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

McFoggy opened this issue Mar 22, 2022 · 1 comment · Fixed by #4843
Labels
Bug thing that needs fixing Priority 2 secondary priority issue Release 8.x work is associated with a specific npm 8 release

Comments

@McFoggy
Copy link

McFoggy commented Mar 22, 2022

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                                                      

> issue-only-allow-npx-package-lock-only@1.0.0 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
@McFoggy McFoggy added Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release labels Mar 22, 2022
@fritzy
Copy link
Contributor

fritzy commented Mar 30, 2022

This makes sense given that --package-lock-only is probably getting applied to npx, which then can't install the script. We need to review whether this behavior is intended.

@fritzy fritzy added the Needs Discussion is pending a discussion label Mar 30, 2022
@fritzy fritzy added Priority 2 secondary priority issue and removed Needs Discussion is pending a discussion Needs Triage needs review for next steps labels Mar 31, 2022
@nlf nlf closed this as completed in #4843 May 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Priority 2 secondary priority issue Release 8.x work is associated with a specific npm 8 release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants