-
Notifications
You must be signed in to change notification settings - Fork 3k
NPM_CONFIG_PREFIX does not work inside a bash script ran via an npm-script #14528
Comments
This is very strange, but probably has to do with how the lifecycle |
Hey, @tuhoojabotti! In response to the comments in https://github.com/npm/docs/issues/768, I think this could definitely be improved in our docs, and we'd be more than happy to merge a clarification of The reason you're seeing this behavior is a mixture of Node's own case-folding logic for environment variables (where it will prefer lowercase versions when both casings are present), and the fact that npm itself sets the lowercase version of all these configurations itself, effectively trumping external user configuration. It's a tricky scenario, but that's the way the cookie crumbles, I guess. :) The way you're setting env variables, btw, will not really work on Windows. Check out Thanks for the submission! I'm closing this issue with |
@zkat thanks for the info! It makes sense now. I know about crossenv, but Windows support is not a problem for my use-case because it is an internal tool. It took me a couple days to track down the problem. At first I thought the problem was Docker. I will work on getting a new pr done. |
@tuhoojabotti Yeah! It's super confusing for sure. Thanks so much for taking the time to cook up that PR! ❤️ |
I'm opening this issue because:
What's going wrong?
Using the environment variable NPM_CONFIG_PREFIX does not work if ran inside a bash script via npm-script.
How can the CLI team reproduce the problem?
test.sh
#!/bin/bash NPM_CONFIG_PREFIX=/tmp/test npm config get prefix npm_config_prefix=/tmp/test npm config get prefix
package.json
Running
./test.sh
directly worksRunning it through an npm script fails
Running directly in an npm script works
Setting the variable uppercase before the script execution fails
Setting the variable lowercase before the script execution works
supporting information:
npm -v
prints: 3.10.8node -v
prints: v7.0.0npm config get registry
prints: https://registry.npmjs.org/The text was updated successfully, but these errors were encountered: