Skip to content

Commit

Permalink
npm-bin: Prefer locally installed npm in Git Bash.
Browse files Browse the repository at this point in the history
Existing behavior invoking npm within a Git Bash session is to prefer
the globally installed instance of `npm`; the instance of npm installed
alongside Node when using the Node installer.

The cmd script, and the shell script, have been modified in the past to
pull a `prefix` setting from the global `npmrc` file, and invoke the
`npm` instance located at the `prefix` location. Because the value of
`prefix` is the user's AppData directory where npm installs new copies
of itself, the user gets the latest installed npm.

However, the setup was not extended to support Git Bash. Therefore Git
Bash users still get the version of npm installed beside Node.

Add support for using the same prefix for invoking the user installed
npm in Git Bash sessions.

PR-URL: npm/npm#11526
Credit: @destroyerofbuilds
Reviewed-By: @iarna
Fixes: #11524
  • Loading branch information
hutson authored and iarna committed Feb 24, 2016
1 parent b63de3c commit d60351c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions bin/npm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ fi
NPM_CLI_JS="$basedir/node_modules/npm/bin/npm-cli.js"

case `uname` in
*MINGW*)
NPM_PREFIX=`"$NODE_EXE" "$NPM_CLI_JS" prefix -g`
NPM_PREFIX_NPM_CLI_JS="$NPM_PREFIX/node_modules/npm/bin/npm-cli.js"
if [ -f "$NPM_PREFIX_NPM_CLI_JS" ]; then
NPM_CLI_JS="$NPM_PREFIX_NPM_CLI_JS"
fi
;;
*CYGWIN*)
NPM_PREFIX=`"$NODE_EXE" "$NPM_CLI_JS" prefix -g`
NPM_PREFIX_NPM_CLI_JS="$NPM_PREFIX/node_modules/npm/bin/npm-cli.js"
Expand Down

0 comments on commit d60351c

Please sign in to comment.