I am new to Macos,I already have nvm,and installed node v6.2.0 and set it as default,but i cannot find node and npm,i also set
export NVM_DIR="/Users/myname/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
in ~/.bashrc and ~/.bash_profile,and print the path
it turns out
192:~ myname$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
and the problem is
192:~ myname$ nvm list
v6.2.0
current -> v6.2.0
node -> stable (-> v6.2.0) (default)
stable -> 6.2 (-> v6.2.0) (default)
iojs -> N/A (default)
lts/* -> lts/boron (-> N/A)
lts/argon -> v4.6.2 (-> N/A)
lts/boron -> v6.9.1 (-> N/A)
192:~ myname$ node -v
-bash: node: command not found
192:~ myname$ npm -v
-bash: npm: command not found
nvm debug?
@PeterDaveHello
$NVM_DIR: '$HOME/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
nvm current: none
which node:
which iojs:
which npm:
npm config get prefix: -bash: npm: command not found
npm root -g: -bash: npm: command not found
@jasminecjc what's the nvm version you are using please?
@PeterDaveHello 0.32.1
@jasminecjc what about the bash version?
@PeterDaveHello sorry i don't know how to check the bash version,can you tell?
bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin16)
Copyright (C) 2007 Free Software Foundation, Inc.
hmmmm ... it's a very old version builtin MacOS, I'm not sure if nvm will work on it, do you have MacPorts or homebrew which can help you upgrade your bash?
just mention, someone tell me i should add node path, are you sure it's nothing about the node path?
Since nvm is a shellscript running on the shell, in your case, a very old bash, I'll guess that it's too old for nvm to run properly, so that you don't have the correct PATH.
@jasminecjc if you don't mind, I'll respectfully suggest you install homebrew first, install coreutils and bash via homebrew, and try nvm again once you installed the new bash and restarted the terminal.
thx,i already have homebrew in my mac,and i am install bash 4.3 now
I already hava bash 4.3, should i reinstall nvm first? @PeterDaveHello
@jasminecjc I don't think so, unless you don't even install nvm properly.
should i restart my mac? because it's still node not found
@jasminecjc you should restart your terminal and make sure you are running the new bash, no need to restart your mac.
I ensured what you said, and when i run nvm debug,it's still the same, maybe it's other problems
@jasminecjc just asking, does your echo $BASH_VERSION shows bash version v4.3?
You need to use /usr/local/bin/bash instead of /bin/bash
Oh....you are right,it's still the old version, but when i check bash --version it's the new version,so what should i do to update the $BATH_VERSION
@jasminecjc chsh can help you change the default version, or, you can just to run run, it'll bring to the new one.
Just tested with bash v3.2 on MacOS, looks like it works fine with my old bash, sorry that the bash upgrade didn't help.
always thx for answer
@jasminecjc are you sourcing nvm.sh in both bashrc and bash_profile? You should be able to use stock bash; you shouldn't need anything from homebrew.
Can you share the contents of your ~/.bashrc and ~/.bash_profile files?
@jasminecjc also, how did you install nvm?
â–¶ nvm debug
nvm --version: v0.33.2
$SHELL: /bin/zsh
$HOME: /Users/liuliang
$NVM_DIR: '$HOME/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
$NVM_NODEJS_ORG_MIRROR: 'https://nodejs.org/dist'
$NVM_IOJS_ORG_MIRROR: 'https://iojs.org/dist'
shell version: 'zsh 5.2 (x86_64-apple-darwin16.0)'
uname -a: 'Darwin 16.7.0 Darwin Kernel Version 16.7.0: Thu Jun 15 17:36:27 PDT 2017; root:xnu-3789.70.16~2/RELEASE_X86_64 x86_64'
OS version: Mac 10.12.6 16G29
curl: /usr/bin/curl, curl 7.54.0 (x86_64-apple-darwin16.0) libcurl/7.54.0 SecureTransport zlib/1.2.8
wget: /usr/local/bin/wget, GNU Wget 1.19.1 built on darwin16.6.0.
git: /usr/bin/git, git version 2.11.0 (Apple Git-81)
nvm current: v4.7.3
which node: $NVM_DIR/versions/node/v4.7.3/bin/node
which iojs: iojs not found
which npm: npm not found
npm config get prefix: nvm:143: command not found: npm
npm root -g: nvm:143: command not found: npm
after using nvm use v4.3.2(switch node version)
run node -v , it workes(print v4.7.3)
but run npm, it failed(print command not found: npm)
installed npm package(before i run into the issue) still work, so it is so amazing
what's run npm? (also, i would uninstall any separate npm package; npm should only ever be installed with node)
Most of the guidelines on nvm miss the fact that you need to enter in each shell:
nvm use node
Please check if node -v works after that. To be able to run it always, use this command:
nvm alias default node
@iburskiy the first time you install a version of node with nvm, it sets it as the default for you; the only users who would be helped by that info are users of nvm from prior to that feature being available.
@ljharb I installed version 0.33.0 and there was no such a feature. So I had to spend some time trying to understand all this on Mavericks. Whereas the latest version of nvm is 0.33.6 according to https://github.com/creationix/nvm
@iburskiy that feature was added in v0.25.0, about 2.5 years ago.
sudo rm -rf ~/.nvm
then reinstall
Closing; happy to reopen if the OP can continue to repro.
Closing; happy to reopen if the OP can continue to repro.
He has installed nvm before, if he wants to reinstall , he should rm the .nvm totally use sudo rm -rf ~/.nvm, it works for me.
Most helpful comment
Most of the guidelines on nvm miss the fact that you need to enter in each shell:
nvm use nodePlease check if
node -vworks after that. To be able to run it always, use this command:nvm alias default node