Operating system and version:
macOS 10.13.6
nvm debug output:
nvm --version: v0.34.0
$TERM_PROGRAM: Apple_Terminal
$SHELL: /bin/zsh
$SHLVL: 1
$HOME: /Users/j
$NVM_DIR: '$HOME/.nvm'
$PATH:
$NVM_DIR/versions/node/v10.16.3/bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Wireshark.app/Contents/MacOS
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'zsh 5.3 (x86_64-apple-darwin17.0)'
uname -a: 'Darwin 17.7.0 Darwin Kernel Version 17.7.0: Sun Jun 2 20:31:42 PDT 2019; root:xnu-4570.71.46~1/RELEASE_X86_64 x86_64'
OS version: Mac 10.13.6 17G8030
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/bin/git, git version 2.17.2 (Apple Git-113)
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
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: v10.16.3
which node: $NVM_DIR/versions/node/v10.16.3/bin/node
which iojs: iojs not found
which npm: $NVM_DIR/versions/node/v10.16.3/bin/npm
npm config get prefix: $NVM_DIR/versions/node/v10.16.3
npm root -g: $NVM_DIR/versions/node/v10.16.3/lib/node_modules
nvm ls output:
v10.11.0
-> v10.16.3
v11.0.0
system
default -> node (-> v11.0.0)
node -> stable (-> v11.0.0) (default)
stable -> 11.0 (-> v11.0.0) (default)
iojs -> N/A (default)
unstable -> N/A (default)
lts/* -> lts/dubnium (-> v10.16.3)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.16.1 (-> N/A)
lts/dubnium -> v10.16.3
How did you install nvm? (e.g. install script in readme, Homebrew):
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
What steps did you perform?
ng new myProject and cd into itng --version, it shows node 11.0.0nvm install 10.16.3 ng --version, it shows node 10.16.3then, after I reopen terminal and in the same project, run ng --version, it shows 11.0.0 as if node version wasn't changed
What happened?
node version changed via nvm use doesn't seem to be persistent and only lasts in a terminal session
What did you expect to happen?
expect angular cli to show the node version that I use nvm to change to
Is there anything in any of your profile files (.bashrc, .bash_profile, .zshrc, etc) that modifies the PATH?
no
Is angular-cli installed on your system node?
Global packages need to be installed on each version of node if you want to use them; better still is to have none of them installed, and use npx ng
@ljharb
1) I probably did. How can i check if I have angular-cli installed on my system node?
2) I will check out what npx ng is. thanks.
3) I tried again without using angular cli ng --version to check node version.
It seems that node version reverts to possibly my system node version after I reopen the terminal. Is that expected?
$ node --version
v11.0.0
$ which node
/Users/j/.nvm/versions/node/v11.0.0/bin/node
$ npm --version
6.10.1
$ which npm
/Users/j/.nvm/versions/node/v11.0.0/bin/npm
$ nvm --version
0.34.0
$ nvm use 10.16.3
Now using node v10.16.3 (npm v6.9.0)
$ node --version
v10.16.3
$ which node
/Users/j/.nvm/versions/node/v10.16.3/bin/node
$ npm --version
6.9.0
$ which npm
/Users/j/.nvm/versions/node/v10.16.3/bin/npm
After that, open a new terminal, node version revers to v11.0.0
$ node --version
v11.0.0
$ which node
/Users/j/.nvm/versions/node/v11.0.0/bin/node
$ npm --version
6.10.1
$ which npm
/Users/j/.nvm/versions/node/v11.0.0/bin/npm
You need to set a default if you want it to stick - nvm alias default node selects the latest.
However, I’d also nvm use system and then npm uninstall -g angular-cli
@ljharb
1) Thanks. The version of node stays persistent after I run nvm alias default VERSION_NUMBER
2) I tried nvm use system to use system-installed version of node and ran npm v but got the following error. That means my system doesn't have node installed?
npm v
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.63.dylib
Referenced from: /usr/local/bin/node
Reason: image not found
3) why should I run npm uninstall -g angular-cli?
in that case that means your npm installation on your system node is broken; you probably should just uninstall your entire system node (how to do that depends on how you installed it).
You should globally uninstall angular-cli because in general nothing should be globally installed, and also if your system node has globally installed things, then that will cause confusion with globally installed things in nvm's node.
Thanks @ljharb
I would use npx to run angular cli instead of installing it globally.
Most helpful comment
Thanks @ljharb
I would use
npxto run angular cli instead of installing it globally.