env: node: No such file or directory in mac
node.jsHomebrewnode.js Problem Overview
I'm searching it in google on how to show the version of node js or how I'm gonna work with npm? If I do this
npm -v
even I already install it using brew install node
. The result is always
env: node: No such file or directory
I already do a lot of command to solve for it, but failed. these are the command that I already try:
sudo apt-get install nodejs-legacy
sudo ln -s /usr/local/bin/node /usr/bin/node
brew unlink node
brew link node
I can't start the task because of this. help me guys. This work before after I used this command brew link --overwrite node
. Now I have problem, i cant work anymore with npm. I'm really new about this. I don't have any idea now on how to fix this.
Update
I already get the list using npm list
command. I also get the idea here link but when I npm install
inside the project. I alwayst get this "result env: node: No such file or directory",even I command npm -v
but If i command it outside my project. It work the npm -v
node.js Solutions
Solution 1 - node.js
I solved it this way:
$ brew uninstall --force node
$ brew uninstall --force npm
after it
$ brew install node
which suggested me to overwrite simlinks
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink share/doc/node/gdbinit
Target /usr/local/share/doc/node/gdbinit
already exists. You may want to remove it:
rm '/usr/local/share/doc/node/gdbinit'
To force the link and overwrite all conflicting files:
brew link --overwrite node
after executing
$ brew link --overwrite node
everything worked again.
Solution 2 - node.js
NOTE: Only mac users!
- uninstall node completely with the commands
curl -ksO https://gist.githubusercontent.com/nicerobot/2697848/raw/uninstall-node.sh
chmod +x ./uninstall-node.sh
./uninstall-node.sh
rm uninstall-node.sh
Or you could check out this website: https://stackoverflow.com/questions/11177954/how-do-i-completely-uninstall-node-js-and-reinstall-from-beginning-mac-os-x
if this doesn't work, you need to remove node via control panel or any other method. As long as it gets removed.
- Install node via this website: https://nodejs.org/en/download/
If you use nvm
, you can use:
nvm install node
You can already check if it works, then you don't need to take the following steps with: npm -v
and then node -v
if you have nvm
installed:
command -v nvm
- Uninstall npm using the following command:
sudo npm uninstall npm -g
Or, if that fails, get the npm source code, and do:
sudo make uninstall
If you have nvm
installed, then use: nvm uninstall npm
- Install npm using the following command:
npm install -g grunt
Solution 3 - node.js
I was getting this env: node: No such file or directory
error when running the job through Jenkins.
What I did to fix it - added export PATH="$PATH:"/usr/local/bin/
at the beginning of the script that Jenkins job executes.
Solution 4 - node.js
I got such a problem after I upgraded my node version with brew. To fix the problem
1)run $brew doctor
to check out if it is successfully installed or not
2) In case you missed clearing any node-related file before, such error log might pop up:
Warning: You have unlinked kegs in your Cellar Leaving kegs unlinked can lead to build-trouble and cause brews that depend on those kegs to fail to run properly once built. node
- Now you are recommended to run brew link command to delete the original node-related files and overwrite new files -
$ brew link node
.
And that's it - everything works again !!!
Solution 5 - node.js
If you're switching from bash to oh my zsh
, you will need to add nvm
's path into the zshrc file.
@Zgpeace's answer here helped solve my issue (on IOS):
- Open the .zshrc file. I used nano:
nano ~/.zshrc
- Add this into the file:
export NVM_DIR=~/.nvm
- Save changes by typing
Ctrl+X
-->Yes
. - Reload the configuration. Type
source $(brew --prefix nvm)/nvm.sh
- Test by typing
nvm --version
. - You'll now be able to see the version. For e.g:
0.37.2
Solution 6 - node.js
It was nvm changing paths for me, this fixed it:
nvm use stable
Solution 7 - node.js
I re-installed node through this link and it fixed it.
I think the issue was that I somehow got node to be in my /usr/bin
instead of /usr/local/bin
.
Solution 8 - node.js
Thanks to this forum. Sharing my notes below.
macOS Monterey version 12.2.1 Chip Apple M1
$ brew uninstall --force node
$ brew uninstall --force npm
$ brew install node
$ brew link --overwrite node
$ brew doctor
$ brew cleanup
$ nvm --version
// 0.35.3
$ nvm use stable
// Now using node v17.6.0 (npm v8.5.1)
$ node -v
// v17.6.0
$ npm -v
// 8.5.1
Solution 9 - node.js
Let's see, I sorted that on a different way. in my case I had as path something like ~/.local/bin
which seems that it is not the way it wants.
Try to use the full path, like /Users/tobias/.local/bin
, I mean, change the PATH
variable from ~/.local/bin
to /Users/tobias/.local/bin
or $HOME/.local/bin
.
Now it works.
Solution 10 - node.js
I get this error running npm start
through PyCharm on Mac. For that the answer is to start PyCharm from the Terminal with open -a '/Applications/PyCharm.app/'
. See https://stackoverflow.com/a/34017083/733092.
For Pycharm Professional, starting from the command line is different. Get the JetBrains Toolbox app, go to Settings, Generate Shell Script, and it will create a ~/pycharm_shell_scripts
for you to run.
Solution 11 - node.js
For mac user using the package manager homebrew:
-brew uninstall node -brew uninstall npm
-brew doctor -brew link node
-node -v (to check node version)
That's all you need.
Solution 12 - node.js
For me, this error occurred when I tried to install a package with sudo npm. This fixed it:
sudo env PATH="$PATH:/usr/local/bin/" npm <rest of command>
Solution 13 - node.js
Working on MacOSx, maven exec not willing to execute a shell script that I could manually execute with desired result. Gave me the same error, solved it as well with
export PATH="$PATH:"/usr/local/bin/ at the beginning of the script
Solution 14 - node.js
I was using fish shell and encountered this problem on my m1 macbook air.
- install nvm
omf install nvm
- add nvm to path by creating this file
~/.config/fish/functions/nvm.fish
- I use vim so
vim ~/.config/fish/functions/nvm.fish
- I use vim so
function nvm
bass source ~/.nvm/nvm.sh --no-use ';' nvm $argv
end
- install node again
nvm install node
It worked for me after that, :) hopefully it does for you too
credit https://eshlox.net/2019/01/27/how-to-use-nvm-with-fish-shell