[Fix] install.sh: run the system npm outside the project
`nvm_check_global_modules` ran `npm --version` and `npm list -g` in `$PWD`, so the project `.npmrc` applied, eg its `logs-dir` on npm v8.11 through v10.5. The "npm unavailable" test put its fake npm on a relative `PATH` entry, which no longer resolves from `/`.
This commit is contained in:
2 files changed
+24
-7
No files matched your search
+3
-2
@@ -403,14 +403,15 @@ nvm_check_global_modules() {
|
||||
*/*) nvm_is_wsl && [ -f "${NPM_COMMAND%/*}/npm.cmd" ] && return 0 ;;
|
||||
esac
|
||||
|
||||
# run npm from `/`, so it does not apply the npmrc of the (untrusted) project that `$PWD` is in
|
||||
local NPM_VERSION
|
||||
NPM_VERSION="$(npm --version)"
|
||||
NPM_VERSION="$(command cd / && npm --version)"
|
||||
NPM_VERSION="${NPM_VERSION:--1}"
|
||||
[ "${NPM_VERSION%%[!-0-9]*}" -gt 0 ] || return 0
|
||||
|
||||
local NPM_GLOBAL_MODULES
|
||||
NPM_GLOBAL_MODULES="$(
|
||||
npm list -g --depth=0 |
|
||||
(command cd / && npm list -g --depth=0) |
|
||||
command sed -e '/ npm@/d' -e '/ (empty)$/d'
|
||||
)"
|
||||
|
||||
|
||||
Reference in new issue
Block a user