A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/npm/npm/issues/14528 below:

NPM_CONFIG_PREFIX does not work inside a bash script ran via an npm-script · Issue #14528 · npm/npm · GitHub

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
{
  "name": "npm-config-test",
  "scripts": {
    "test": "./test.sh",
    "test2": "NPM_CONFIG_PREFIX=/tmp/test npm config get prefix && npm_config_prefix=/tmp/test npm config get prefix",
    "test3": "NPM_CONFIG_PREFIX=/tmp/test ./test.sh",
    "test4": "npm_config_prefix=/tmp/test ./test.sh"
  }
}
Running ./test.sh directly works
➜  npm-config-test ./test.sh
/tmp/test
/tmp/test
Running it through an npm script fails
➜  npm-config-test npm test

> npm-config-test@1.0.0 test /home/$USER/npm-config-test
> ./test.sh

/home/$USER/n
/tmp/test
Running directly in an npm script works
➜  npm-config-test npm run test2

> npm-config-test@1.0.0 test2 /home/$USER/npm-config-test
> NPM_CONFIG_PREFIX=/tmp/test npm config get prefix && npm_config_prefix=/tmp/test npm config get prefix

/tmp/test
/tmp/test
Setting the variable uppercase before the script execution fails
➜  npm-config-test npm run test3

> npm-config-test@1.0.0 test3 /home/$USER/npm-config-test
> NPM_CONFIG_PREFIX=/tmp/test ./test.sh

/home/$USER/n
/tmp/test
Setting the variable lowercase before the script execution works
➜  npm-config-test npm run test4

> npm-config-test@1.0.0 test4 /home/$USER/npm-config-test
> npm_config_prefix=/tmp/test ./test.sh

/tmp/test
/tmp/test
supporting information:

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4