Installation fails with npm v7
See original GitHub issueFor some reason, npm install -g npq
fails during the postinstall script when using Node 14.16.0. In my case Node is installed with nvm, however, the npq install works fine on 14.15.4.
Edit (see update below): npm install -g npq
fails during the postinstall script when using npm v7.
Expected Behavior
Installation leads to the usual “Thank you for installing npq… do you want to add aliases?” prompt. This works fine with Node 14.16.1 and npm 6.14.12.
Current Behavior
I’ve tried both a local install (without -g) and the normal global install, with the same result. The prompt text is printed in the middle of the error, before it exits:
npm ERR! path /Users/andron/.nvm/versions/node/v14.16.0/lib/node_modules/npq
npm ERR! command failed
npm ERR! signal SIGINT
npm ERR! command sh -c node scripts/postinstall.js
npm ERR! Thank you for installing npq! We want to help you make conscious decisions before installing potentially dangerous packages.
npm ERR! To do that, we can alias npm and yarn to npq, so that e.g. `npm install <package>` will first use npq to verify the package and prompt you if it finds any issues.
npm ERR! ? Do you want to add zsh aliases for npm and yarn? (Y/n)
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/andron/.npm/_logs/2021-04-07T14_08_12_889Z-debug.log
Relevant lines from the debug log:
1016 info run npq@2.0.16 postinstall node_modules/npq node scripts/postinstall.js
1017 info run npq@2.0.16 postinstall { code: null, signal: 'SIGINT' }
1018 timing reify:rollback:createSparse Completed in 670ms
1019 timing reify:rollback:retireShallow Completed in 0ms
1020 timing command:install Completed in 5030ms
1021 verbose stack Error: command failed
1021 verbose stack at ChildProcess.<anonymous> (/Users/andron/.nvm/versions/node/v14.16.0/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/index.js:64:27)
1021 verbose stack at ChildProcess.emit (events.js:315:20)
1021 verbose stack at maybeClose (internal/child_process.js:1048:16)
1021 verbose stack at Socket.<anonymous> (internal/child_process.js:439:11)
1021 verbose stack at Socket.emit (events.js:315:20)
1021 verbose stack at Pipe.<anonymous> (net.js:673:12)
1022 verbose pkgid npq@2.0.16
1023 verbose cwd /Users/andron
1024 verbose Darwin 19.6.0
1025 verbose argv "/Users/andron/.nvm/versions/node/v14.16.0/bin/node" "/Users/andron/.nvm/versions/node/v14.16.0/bin/npm" "install" "-g" "npq"
1026 verbose node v14.16.0
1027 verbose npm v7.8.0
1028 error path /Users/andron/.nvm/versions/node/v14.16.0/lib/node_modules/npq
1029 error command failed
1030 error signal SIGINT
1031 error command sh -c node scripts/postinstall.js
1032 error Thank you for installing npq! We want to help you make conscious decisions before installing potentially dangerous packages.
1032 error To do that, we can alias npm and yarn to npq, so that e.g. `npm install <package>` will first use npq to verify the package and prompt you if it finds any issues.
1032 error ? Do you want to add zsh aliases for npm and yarn? (Y/n)
1033 verbose exit 1
Your Environment (edited per update):
- Version used: 2.0.16
- Environment name and version:
- Tested with Node.js v14.16.0, 14.16.1, and 15.14.0,
- Bug occurs with npm 7.7.6 and 7.8.0 (haven’t tested further)
- installed with nvm 0.38.0,
- zsh shell
- Operating System and version (desktop or mobile): macOS catalina 10.15.7
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (8 by maintainers)
Top Results From Across the Web
npm 7 is now generally available! - The GitHub Blog
Automatically installing peer dependencies is an exciting new feature introduced in npm 7. In previous versions of npm (4-6), peer dependencies ...
Read more >Build fails while installing npm v7 - Feedback & Bug Reports
I'm using the node:current Docker image and install the latest npm version before installing/running tests/linters/etc… I'm seeing the same ...
Read more >Try the latest stable version of npm
Option 1: edit your Windows installation's PATH to put %appdata%\npm before %ProgramFiles%\nodejs . · Option 2: remove both of · Option 3: Navigate...
Read more >Windows 10 with early build npm fails to install any modules ...
In trying to find a way around the above problem I have installed WSL for Windows 10 with Ubuntu Linux. This allowed me...
Read more >Npm install command failing with message "could not find ...
When I run the npm install command, npm starts downloading the dependencies. But then, suddenly, it stops with the error:
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think it is possible that npm7 is now allowing the sort of interactivity that the preinstall script in npq is defined.
I recommend that the fix would be to detect if we’re being installed with npm >= 7 and if so to not run that bash script, but instead print to stdout the instructions and recommendation of running that script to get npq added to the shell preferences. We’ll likely maybe need to expose another bin that installs that, something like
npq-install-shell
You can use the
npm_config_user_agent
variable. this variable contains some info about the system including the npm version.