Hi folks, in my latest nvm configuration I am now seeing the nvm is not compatible with the npm config "prefix" option error when opening the VS Code Terminal. (Opening a bash session using Terminal.app doesn't show any warnings or errors.)
I skimmed #855 and didn't find an obvious solution - that issue made this error sound like an unfortunate bug in nvm.sh so I was hoping there'd be a permanent solution that didn't require us to run another command every time a shell is opened.
nvm debug output:nvm --version: v0.33.5
$TERM_PROGRAM: vscode
$SHELL: /bin/bash
$HOME: /Users/mike
$NVM_DIR: '$HOME/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin17)'
uname -a: 'Darwin 17.3.0 Darwin Kernel Version 17.3.0: Thu Nov 9 18:09:22 PST 2017; root:xnu-4570.31.3~1/RELEASE_X86_64 x86_64'
OS version: Mac 10.13.2 17C88
curl: /usr/bin/curl, curl 7.54.0 (x86_64-apple-darwin17.0) libcurl/7.54.0 LibreSSL/2.0.20 zlib/1.2.11 nghttp2/1.24.0
wget: not found
git: /usr/local/bin/git, git version 2.15.0
grep: /usr/bin/grep, grep (BSD grep) 2.5.1-FreeBSD
awk: /usr/bin/awk, awk version 20070501
sed: illegal option -- -
usage: sed script [-Ealn] [-i extension] [file ...]
sed [-Ealn] [-i extension] [-e script] ... [-f script_file] ... [file ...]
sed: /usr/bin/sed,
cut: illegal option -- -
usage: cut -b list [-n] [file ...]
cut -c list [file ...]
cut -f list [-s] [-d delim] [file ...]
cut: /usr/bin/cut,
basename: illegal option -- -
usage: basename string [suffix]
basename [-a] [-s suffix] string [...]
basename: /usr/bin/basename,
rm: illegal option -- -
usage: rm [-f | -i] [-dPRrvW] file ...
unlink file
rm: /bin/rm,
mkdir: illegal option -- -
usage: mkdir [-pv] [-m mode] directory ...
mkdir: /bin/mkdir,
xargs: illegal option -- -
usage: xargs [-0opt] [-E eofstr] [-I replstr [-R replacements]] [-J replstr]
[-L number] [-n number [-x]] [-P maxprocs] [-s size]
[utility [argument ...]]
xargs: /usr/bin/xargs,
nvm current: system
which node: /usr/local/bin/node
which iojs:
which npm: /usr/local/bin/npm
npm config get prefix: /usr/local
npm root -g: /usr/local/lib/node_modules
nvm ls output: v6.5.0
v6.11.2
v6.11.4
v8.9.1
-> system
default -> lts/* (-> v8.9.1)
node -> stable (-> v8.9.1) (default)
stable -> 8.9 (-> v8.9.1) (default)
iojs -> N/A (default)
lts/* -> lts/carbon (-> v8.9.1)
lts/argon -> v4.8.6 (-> N/A)
lts/boron -> v6.12.0 (-> N/A)
lts/carbon -> v8.9.1
nvm? (e.g. install script in readme, homebrew):brew uninstall nvm results in "Error: No such keg: /usr/local/Cellar/nvm" so it must have been the curl approachnvm alias default lts/*nvm is not compatible with the npm config "prefix" option: currently set to "/usr/local"
Run `npm config delete prefix` or `nvm use --delete-prefix v8.9.1 --silent` to unset it.
.bashrc, .bash_profile, .zshrc, etc) that modifies the PATH?.profile includes this:PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"
export PATH
D'oh! Sorry, I didn't spot #1647 and #1652 until after filing this and continuing to dig around the interwebs. Feel free to close this as a duplicate of those.
Sounds good :-)
I fixed this temporarily by adding nvm use node to the end of my .bash_profile after the nvm path export.
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
nvm use node
c
@danieldbird you shouldn't need that if you do nvm alias default node once in the terminal.
@ljharb only to get around the
nvm is not compatible with the npm config "prefix" option: currently set to "/usr/local"
Runnpm config delete prefixornvm use --delete-prefix v9.6.1 --silentto unset it.
error in VSCode and Atom. It works fine in the native terminal, or iTerm, and throws no error message.
This seems to be happening because no version of node is being used when first opening the integrated terminal in VSCode or Atom.
Edit: Even after running nvm alias default node
@danieldbird can either VSCode or Atom be made to use a login shell?
@ljharb I saw another discussion you were a part of that helped me. It appears I have fixed the issue. What I did was ensure the following were uninstalled brew uninstall node, brew uninstall npm, brew uninstall nvm, then I ensured the hidden home directories were removed .npm, .nvm, then i used the nvm curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash install command. And then I installed node using the OS installer. All is working fine now in both VSCode, Atom, and native terminals, Terminal and iTerm. Thanks.
i have the same problem ,
nvm is not compatible with the npm config "prefix" option: currently set to "/usr/local/Cellar/node@6/6.12.3"
Run npm config delete prefix or nvm use --delete-prefix v8.9.4 --silent to unset it.
it worked after i delete the folder:
rm -rf /usr/local/Cellar/node@6
Fix here : https://github.com/Microsoft/vscode-docs/blob/master/docs/editor/integrated-terminal.md#why-is-nvm-complaining-about-a-prefix-option-when-the-integrated-terminal-is-launched
That fix doesn't seem to resolve it for me.
As a workaround, I've redirected the output to /dev/null and called nvm use node in my ~/.bashrc
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" 2>/dev/null
$(nvm use node) 2>/dev/null
@ThibaudCrespin this solved my problem. cheers
@ThibaudCrespin Great! Best!
@ThibaudCrespin it works well! thanks!
i have the same problem,
rm -R /usr/local/lib/node_modules/npm
rm -R /usr/local/bin/npm /usr/local/lib/node_modules/npm/bin/npm-cli.js
this resolve my problem, because I install node use brew install node brefore.
you need uninstall node and npm when use nvm.
Tried lots of these things, but the only thing that worked for me was installing node/npm via the installer from nodejs.org then adding export PATH=$PATH:/usr/local/git/bin in my ~/.bash_profile
Hope this helps someone.
brew uninstall --ignore-dependencies node (igonore-deps because I had yarn installed) worked for me. What @webkong said was accurate. At the end of the day, if you have nvm installed then there's no need for a "global" node/npm install. Remove them (however you installed them determines how that gets done) and you're good.
1) brew uninstall node
2)
https://github.com/Microsoft/vscode-docs/blob/master/docs/editor/integrated-terminal.md#why-is-nvm-complaining-about-a-prefix-option-when-the-integrated-terminal-is-launched
3) reinstall nvm
`curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash`
Thanks @Guang1234567, it helps
@greentornado
glad works for you, haha.
@ThibaudCrespin Finally the solution that works for me. Thank you very much!
Most helpful comment
Fix here : https://github.com/Microsoft/vscode-docs/blob/master/docs/editor/integrated-terminal.md#why-is-nvm-complaining-about-a-prefix-option-when-the-integrated-terminal-is-launched