Nvm: vscode terminal: nvm is not compatible with the npm config "prefix" option

Created on 23 Jul 2020  ·  12Comments  ·  Source: nvm-sh/nvm

Operating system and version:

macOS 10.15.6 (19G73)

nvm debug output:


in vscode:

nvm --version: v0.35.3
$TERM_PROGRAM: vscode
$SHELL: /bin/zsh
$SHLVL: 1
${HOME}: /Users/rublev
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: /usr/local/sbin:${HOME}/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:${HOME}/Library/Python/2.7/bin:/usr/local/sbin:${HOME}/bin
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'zsh 5.7.1 (x86_64-apple-darwin19.0)'
uname -a: 'Darwin 19.6.0 Darwin Kernel Version 19.6.0: Sun Jul 5 00:43:10 PDT 2020; root:xnu-6153.141.1~9/RELEASE_X86_64 x86_64'
OS version: Mac 10.15.6 19G73
curl: /usr/bin/curl, curl 7.64.1 (x86_64-apple-darwin19.0) libcurl/7.64.1 (SecureTransport) LibreSSL/2.8.3 zlib/1.2.11 nghttp2/1.39.2
wget: /usr/local/bin/wget, GNU Wget 1.20.3 built on darwin19.0.0.
sed: /usr/bin/sed
cut: /usr/bin/cut
basename: /usr/bin/basename
rm: /bin/rm
mkdir: /bin/mkdir
xargs: /usr/bin/xargs
git: /usr/local/bin/git, git version 2.24.1
grep: /usr/bin/grep, grep (BSD grep) 2.5.1-FreeBSD
awk: /usr/bin/awk, awk version 20070501
nvm current: none
which node: node not found
which iojs: iojs not found
which npm: npm not found
npm config get prefix: nvm:199: command not found: npm
npm root -g: nvm:199: command not found: npm

in iterm:

nvm --version: v0.35.3
$TERM_PROGRAM: iTerm.app
$SHELL: /bin/zsh
$SHLVL: 1
${HOME}: /Users/rublev
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: ${NVM_DIR}/versions/node/v10.22.0/bin:/usr/local/sbin:${HOME}/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:${HOME}/Library/Python/2.7/bin
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'zsh 5.7.1 (x86_64-apple-darwin19.0)'
uname -a: 'Darwin 19.6.0 Darwin Kernel Version 19.6.0: Sun Jul 5 00:43:10 PDT 2020; root:xnu-6153.141.1~9/RELEASE_X86_64 x86_64'
OS version: Mac 10.15.6 19G73
curl: /usr/bin/curl, curl 7.64.1 (x86_64-apple-darwin19.0) libcurl/7.64.1 (SecureTransport) LibreSSL/2.8.3 zlib/1.2.11 nghttp2/1.39.2
wget: /usr/local/bin/wget, GNU Wget 1.20.3 built on darwin19.0.0.
sed: /usr/bin/sed
cut: /usr/bin/cut
basename: /usr/bin/basename
rm: /bin/rm
mkdir: /bin/mkdir
xargs: /usr/bin/xargs
git: /usr/local/bin/git, git version 2.24.1
grep: /usr/bin/grep, grep (BSD grep) 2.5.1-FreeBSD
awk: /usr/bin/awk, awk version 20070501
nvm current: v10.22.0
which node: ${NVM_DIR}/versions/node/v10.22.0/bin/node
which iojs: iojs not found
which npm: ${NVM_DIR}/versions/node/v10.22.0/bin/npm
npm config get prefix: ${NVM_DIR}/versions/node/v10.22.0
npm root -g: ${NVM_DIR}/versions/node/v10.22.0/lib/node_modules

nvm ls output:


       v10.16.3
       v10.22.0
default -> 10 (-> v10.22.0)
node -> stable (-> v10.22.0) (default)
stable -> 10.22 (-> v10.22.0) (default)
iojs -> N/A (default)
unstable -> N/A (default)
lts/* -> lts/erbium (-> N/A)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.22.0
lts/erbium -> v12.18.3 (-> N/A)

in iterm:

       v10.16.3
->     v10.22.0
default -> 10 (-> v10.22.0)
node -> stable (-> v10.22.0) (default)
stable -> 10.22 (-> v10.22.0) (default)
iojs -> N/A (default)
unstable -> N/A (default)
lts/* -> lts/erbium (-> N/A)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.22.0
lts/erbium -> v12.18.3 (-> N/A)

How did you install nvm?

homebrew

What steps did you perform?

brew update
brew install nvm

What happened?

success

What did you expect to happen?

success, but nvm does not work inside vscode integrated terminal. looks like the path is all mangled. as such i am unable to use node or npm. all commands follow with the following:

Error: Cannot find module '"/Users/rublev/Library/Application'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at Module._preloadModules (internal/modules/cjs/loader.js:901:12)
    at preloadModules (internal/bootstrap/node.js:602:7)
    at startup (internal/bootstrap/node.js:273:9)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
nvm is not compatible with the npm config "prefix" option: currently set to ""
Run `nvm use --delete-prefix v10.22.0 --silent` to unset it.
rublev@andreis-MBP remote-yes % 

Is there anything in any of your profile files that modifies the PATH?

# # custom executables like st
export PATH=$HOME/bin:$PATH
# # homebrew path
export PATH="/usr/local/sbin:$PATH"

# # aliases
alias ls='ls -GFhal'
alias ..='cd ..'
alias gi="git init && git commit --allow-empty -m 'init commit'"
alias dev='cd ~/dev'
alias tree='tree -I 'node_modules' .'
alias vim='nvim'
alias ios='open -a /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app'
alias ytdl='youtube-dl -f 'bestvideo+bestaudio' --merge-output-format mkv'

# journal
EDITOR=nano
journal() {
    mkdir -p ~/journal/`date +%Y`
    $EDITOR ~/journal/`date +%Y`/`date +%m-%d`
}
alias j=journal

source ~/.zsh/themes/distroprompt.zsh

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

Most helpful comment

I'm facing the same issue when running nvm use 10
when running nvm use 12 / nvm use 14 it works

internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module '"/Users/bnaya/Library/Application'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at Module._preloadModules (internal/modules/cjs/loader.js:901:12)
    at preloadModules (internal/bootstrap/node.js:602:7)
    at startup (internal/bootstrap/node.js:273:9)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
nvm is not compatible with the npm config "prefix" option: currently set to ""
Run `npm config delete prefix` or `nvm use --delete-prefix v10.22.0` to unset it.

All 12 comments

What does whoami print out?

What does whoami print out?

rublev

nvm debug in vscodium terminal:

nvm --version: v0.35.3
$TERM_PROGRAM: vscode
$SHELL: /bin/zsh
$SHLVL: 1
${HOME}: /Users/rublev
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: /usr/local/sbin:${HOME}/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'zsh 5.7.1 (x86_64-apple-darwin19.0)'
uname -a: 'Darwin 19.6.0 Darwin Kernel Version 19.6.0: Sun Jul 5 00:43:10 PDT 2020; root:xnu-6153.141.1~9/RELEASE_X86_64 x86_64'
OS version: Mac 10.15.6 19G73
curl: /usr/bin/curl, curl 7.64.1 (x86_64-apple-darwin19.0) libcurl/7.64.1 (SecureTransport) LibreSSL/2.8.3 zlib/1.2.11 nghttp2/1.39.2
wget: /usr/local/bin/wget, GNU Wget 1.20.3 built on darwin19.0.0.
sed: /usr/bin/sed
cut: /usr/bin/cut
basename: /usr/bin/basename
rm: /bin/rm
mkdir: /bin/mkdir
xargs: /usr/bin/xargs
git: /usr/local/bin/git, git version 2.24.1
grep: /usr/bin/grep, grep (BSD grep) 2.5.1-FreeBSD
awk: /usr/bin/awk, awk version 20070501
nvm current: none
which node: node not found
which iojs: iojs not found
which npm: npm not found
npm config get prefix: nvm:199: command not found: npm
npm root -g: nvm:199: command not found: npm

nvm debug in iterm2:

nvm --version: v0.35.3
$TERM_PROGRAM: iTerm.app
$SHELL: /bin/zsh
$SHLVL: 1
${HOME}: /Users/rublev
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: ${NVM_DIR}/versions/node/v10.22.0/bin:/usr/local/sbin:${HOME}/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:${HOME}/Library/Python/2.7/bin
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'zsh 5.7.1 (x86_64-apple-darwin19.0)'
uname -a: 'Darwin 19.6.0 Darwin Kernel Version 19.6.0: Sun Jul 5 00:43:10 PDT 2020; root:xnu-6153.141.1~9/RELEASE_X86_64 x86_64'
OS version: Mac 10.15.6 19G73
curl: /usr/bin/curl, curl 7.64.1 (x86_64-apple-darwin19.0) libcurl/7.64.1 (SecureTransport) LibreSSL/2.8.3 zlib/1.2.11 nghttp2/1.39.2
wget: /usr/local/bin/wget, GNU Wget 1.20.3 built on darwin19.0.0.
sed: /usr/bin/sed
cut: /usr/bin/cut
basename: /usr/bin/basename
rm: /bin/rm
mkdir: /bin/mkdir
xargs: /usr/bin/xargs
git: /usr/local/bin/git, git version 2.24.1
grep: /usr/bin/grep, grep (BSD grep) 2.5.1-FreeBSD
awk: /usr/bin/awk, awk version 20070501
nvm current: v10.22.0
which node: ${NVM_DIR}/versions/node/v10.22.0/bin/node
which iojs: iojs not found
which npm: ${NVM_DIR}/versions/node/v10.22.0/bin/npm
npm config get prefix: ${NVM_DIR}/versions/node/v10.22.0
npm root -g: ${NVM_DIR}/versions/node/v10.22.0/lib/node_modules

Looks like vscode's terminal isn't sourcing nvm.sh. Perhaps it doesn't invoke a login shell?

Looks like vscode's terminal isn't sourcing nvm.sh. Perhaps it doesn't invoke a login shell?

I'm not sure how to check if it does or know what it should be doing :| When I do run nvm use --delete-prefix v10.22.0 --silent then node works but then NPM errors out:

internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module '"/Users/rublev/Library/Application'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at Module._preloadModules (internal/modules/cjs/loader.js:901:12)
    at preloadModules (internal/bootstrap/node.js:602:7)
    at startup (internal/bootstrap/node.js:273:9)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
nvm is not compatible with the npm config "prefix" option: currently set to ""
Run `nvm use --delete-prefix v10.22.0 --silent` to unset it.
$ nvm use --delete-prefix v10.22.0 --silent   
internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module '"/Users/rublev/Library/Application'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at Module._preloadModules (internal/modules/cjs/loader.js:901:12)
    at preloadModules (internal/bootstrap/node.js:602:7)
    at startup (internal/bootstrap/node.js:273:9)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module '"/Users/rublev/Library/Application'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at Module._preloadModules (internal/modules/cjs/loader.js:901:12)
    at preloadModules (internal/bootstrap/node.js:602:7)
    at startup (internal/bootstrap/node.js:273:9)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
$ node -v
v10.22.0
$ npm -v
internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module '"/Users/rublev/Library/Application'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at Module._preloadModules (internal/modules/cjs/loader.js:901:12)
    at preloadModules (internal/bootstrap/node.js:602:7)
    at startup (internal/bootstrap/node.js:273:9)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)

Magically fixed itself. How? No idea. Restarted the app and it updated it's version and I guess it got patched. Thanks anyways.

I'm facing the same issue when running nvm use 10
when running nvm use 12 / nvm use 14 it works

internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module '"/Users/bnaya/Library/Application'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at Module._preloadModules (internal/modules/cjs/loader.js:901:12)
    at preloadModules (internal/bootstrap/node.js:602:7)
    at startup (internal/bootstrap/node.js:273:9)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
nvm is not compatible with the npm config "prefix" option: currently set to ""
Run `npm config delete prefix` or `nvm use --delete-prefix v10.22.0` to unset it.

@Bnaya that implies the unquoted, unescapd space in Application Support is breaking things; it might be a bug in your profile files?

Its same error rublev has, and happening only with node 10,
Im not sure how to debug it further/what setting i can change

Also experiencing this issue, specifically with node v10.22.0 There's no actual mention of "Application Support" in my profile files so I'm assuming it's a bug in another place. Any change this issue can be opened up again?

@reaktivo can you also provide the output of whoami, and nvm debug in both the normal terminal and vscode’s?

@ljharb I noticed too that this only happens in vscode's terminal, not on iTerm, but it's unclear what they do differently. Here's the output of both whoami and nvm debug:

bananas ❯ whoami    
at-mbp-9
bananas ❯ nvm debug
nvm --version: v0.35.3
$TERM_PROGRAM: vscode
$SHELL: /bin/zsh
$SHLVL: 1
${HOME}: /Users/at-mbp-9
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: /usr/local/opt/icu4c/sbin:/usr/local/opt/icu4c/bin:/usr/local/opt/icu4c/sbin:/usr/local/opt/icu4c/bin:${HOME}/google-cloud-sdk/bin:${HOME}/.rbenv/shims:${HOME}/bin:${HOME}/.npm-global/bin:${HOME}/.local/bin:/usr/local/opt/node@12/bin:${HOME}/.cargo/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/usr/local/opt/icu4c/sbin:/usr/local/opt/icu4c/bin:${HOME}/google-cloud-sdk/bin:${HOME}/.rbenv/shims:${HOME}/bin:${HOME}/.npm-global/bin:${HOME}/.local/bin:/usr/local/opt/node@12/bin:${HOME}/.cargo/bin
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'zsh 5.7.1 (x86_64-apple-darwin19.0)'
uname -a: 'Darwin 19.4.0 Darwin Kernel Version 19.4.0: Wed Mar 4 22:28:40 PST 2020; root:xnu-6153.101.6~15/RELEASE_X86_64 x86_64'
OS version: Mac 10.15.4 19E287
curl: /usr/bin/curl, curl 7.64.1 (x86_64-apple-darwin19.0) libcurl/7.64.1 (SecureTransport) LibreSSL/2.8.3 zlib/1.2.11 nghttp2/1.39.2
wget: /usr/local/bin/wget, GNU Wget 1.20.3 built on darwin19.0.0.
sed: /usr/bin/sed
cut: /usr/bin/cut
basename: /usr/bin/basename
rm: /bin/rm
mkdir: /bin/mkdir
xargs: /usr/bin/xargs
git: /usr/local/bin/git, git version 2.27.0
ls: grep:: No such file or directory
grep: grep: aliased to grep  --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn} (grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn}), grep (BSD grep) 2.5.1-FreeBSD
awk: /usr/bin/awk, awk version 20070501
nvm current: none
which node: node not found
which iojs: iojs not found
which npm: ${HOME}/.npm-global/bin/npm
npm config get prefix: env: node: No such file or directory
npm root -g: env: node: No such file or directory

@reaktivo it'd be helpful to see a diff of those commands run in both places :-)

Was this page helpful?
0 / 5 - 0 ratings