This isn't really a bug, but raising it to discuss the potential impact of changes to npx
in CI environments.
npx mocha
Need to install the following packages:
mocha
Ok to proceed? (y)
npx -y mocha
works to get the automatic install behaviour, but that would require users to update their CI scripts.
Also, npx -y mocha
errors in npm@6 with:
npx -y mocha
ERROR: You must supply a command.
Execute binaries from npm packages.
npx [options] <command>[@version] [command-arg]...
I think that would complicate the logic required in CI scripts when running across multiple Node.js/npm versions.
_Just using Mocha as an example. In Node.js, we use npx in our GH Actions configuration, which I suspect would be broken when GH Actions updates to use a version of Node.js containing npm@7._
npx <module>
in a CI enironment./cc @MylesBorins @richardlau
@ruyadorno mentioned in the slack conversation that this was an intentional breaking change, could someone link to the context for that decision?
hi @BethGriggs thanks for letting us know 馃槃
It's worth mentioning that for non-interactive terminals we are going to patch (ref #1936) npx
to only WARN instead of throwing so any combination of Unix pipelines would also avoid the prompt/confirmation:
npx mocha < /dev/null
as also mentioned in the slack channel: npm_config_yes=true npx mocha
is the working npm6-7 compat version of it
we published 7.0.0-rc.4 today that skips the prompt, but prints a warning, when run in a non-interactive environment. that way you're still alerted that something is being installed but we do not break in CI environments.
for interactive environments the above workaround should do the trick.
can you let us know if this resolves your issue @BethGriggs?
we published 7.0.0-rc.4 today that skips the prompt, but prints a warning, when run in a non-interactive environment. that way you're still alerted that something is being installed but we do not break in CI environments.
for interactive environments the above workaround should do the trick.
can you let us know if this resolves your issue @BethGriggs?
root@localhost ~# npm install -g [email protected]
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'agentkeepalive'
npm ERR! Require stack:
npm ERR! - /usr/local/lib/node_modules/npm/node_modules/make-fetch-happen/agent.js
npm ERR! - /usr/local/lib/node_modules/npm/node_modules/make-fetch-happen/index.js
npm ERR! - /usr/local/lib/node_modules/npm/node_modules/npm-registry-fetch/index.js
npm ERR! - /usr/local/lib/node_modules/npm/lib/utils/metrics.js
npm ERR! - /usr/local/lib/node_modules/npm/lib/npm.js
npm ERR! - /usr/local/lib/node_modules/npm/lib/cli.js
npm ERR! - /usr/local/lib/node_modules/npm/bin/npm-cli.js
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-10-10T03_17_28_890Z-debug.log
can you let us know if this resolves your issue @BethGriggs?
I think the concern has been addressed to reduce the impact in CI environments, thanks!
closing since the original issue is resolved.
@gengjiawen if you're able to reproduce the problem you had updating, please do open another issue and we can discuss it there
FWIW, I bumped into this in TravisCI: https://travis-ci.com/github/kentcdodds/advanced-react-hooks/builds/191260988
I think that @BethGriggs' original concern is still an issue 馃槵
hmmm 馃 maybe we should also check for the environment using @npmcli/ci-detect
on top of checking for process.stdin.isTTY
@nlf ?
Hitting this too, it broken all our CI scripts... Why did you introduce a breaking change in a minor/patch release?
For anyone having this issue on Circle CI, you can set a global environment variable to set the npm_config_yes
variable to true
to all your jobs
@FezVrasta the change came in the 7.0.0 Semver-Major change. We thought we fixed the CI issue by checking for TTY, but it seems there are edge cases we missed. Looks like #2047 is open to hopefully fix this for more CI environments
we published 7.0.6 today that should hopefully resolve this. we now skip the prompt entirely if you appear to be running in a CI environment.
let us know if you continue to have issues!
Works for us now: https://github.com/testing-library/react-testing-library/pull/809/files
Thank you for the quick fix!
Question: when npx7 prompts and then user installs the missing package,
Most helpful comment
we published 7.0.6 today that should hopefully resolve this. we now skip the prompt entirely if you appear to be running in a CI environment.
let us know if you continue to have issues!