Nvm: how to avoid env: node: No such file or directory

Created on 8 Jan 2018  Â·  10Comments  Â·  Source: nvm-sh/nvm

  • Operating system and version:
    macOS 10.13.2 (17C88)
  • nvm debug output:

nvm --version: v0.33.8
$TERM_PROGRAM: iTerm.app
$SHELL: /usr/local/bin/zsh
$HOME: /Users/song
$NVM_DIR: '$HOME/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'zsh 5.4.2 (x86_64-apple-darwin15.6.0)'
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: /usr/local/bin/wget, GNU Wget 1.19.2 built on darwin15.6.0.
git: git: aliased to hub (hub), 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: rm: aliased to trash (trash),
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: v8.9.4
which node: $NVM_DIR/versions/node/v8.9.4/bin/node
which iojs: iojs not found
which npm: $NVM_DIR/versions/node/v8.9.4/bin/npm
npm config get prefix: $NVM_DIR/versions/node/v8.9.4
npm root -g: $NVM_DIR/versions/node/v8.9.4/lib/node_modules

  • nvm ls output:

default -> 8 (-> v8.9.4)
node -> stable (-> v8.9.4) (default)
stable -> 8.9 (-> v8.9.4) (default)
iojs -> N/A (default)

  • How did you install nvm? (e.g. install script in readme, homebrew):
    install script
  • What steps did you perform?
    I commented the loading nvm script in shell to make my terminal loads faster, then load nvm whenever I need Node.js
  • What happened?
    env: node: No such file or directory shows up every new terminal opened

  • What did you expect to happen?
    nothing like that shows up even I am not loading nvm(or, I am not using Node.js)

  • Is there anything in any of your profile files (.bashrc, .bash_profile, .zshrc, etc) that modifies the PATH?

  • If you are having installation issues, or getting "N/A", what does curl -I --compressed -v https://nodejs.org/dist/ print out?


performance

Most helpful comment

On macOS High Sierra, I had to run sudo chown -R $(whoami) $(brew --prefix)/*
source
and then run brew link --overwrite node

All 10 comments

Try nvm alias default node

@ljharb thanks for the quick response, but I tried that with no luck. My guess is that aliasing in nvm would not work since I am not loading nvm when I start the terminal. Can I just symlink the /usr/bin/node with nvm's node in shell?

You definitely don’t want to do that. Why aren’t you loading nvm in your profile files? That’s required to be able to use nvm.

Ok, thanks for clarifying. Well, I use terminal a lot and nvm adds about 2s to my shell's starting time, which is annoying to me. I only use node occasionally.

The confusing part is that I should be ok to not use node. while after installing nvm, it will always keep hinting for not having unexecutatble node in /bin.

What do you mean by “hinting”? If you have something in your profile files that references node, that might do it.

@ljharb sorry for the confusion, I was meaning env: node: No such file or directory. After another peek, it seems the long loading time is an issue posted by others at multiple times, so I am closing this one. FWIW, my workaround is to use nvm in bash instead of zshell.

On macOS High Sierra, I had to run sudo chown -R $(whoami) $(brew --prefix)/*
source
and then run brew link --overwrite node

use this comment to create a symlink:

sudo ln -s "$(which node)" /usr/bin/node

On macOS High Sierra, I had to run sudo chown -R $(whoami) $(brew --prefix)/*
source
and then run brew link --overwrite node

@RyanPWalker this would only work if you installed node through homebrew. This wouldn't work if you opted not to install node and only use nvm directly.

@mrsoftware's suggestion would work in this case assuming that you use bash, and not something else like fish. You'll have to re-link it though each time you change your node version if in case you want those shebang lines to use the selected node version.

edit: or if linking to /usr/bin/node is not permitted, you can link it to /usr/local/bin. Those shebangs should still work with that.

Was this page helpful?
0 / 5 - 0 ratings