75
votes

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

10
try out npm list then you can see all versions of every package installed. If you want a specific file on mac use npm list -g | grep (module-name)King Reload
I already get the list using that command. I also get the idea here stackoverflow.com/questions/11177954/…. but when I npm install inside the project. I alwayst get this "result env: node: No such file or directory" but If i command it outside my project. It work the npm -vuser3818576
you need to set up your server inside the file directory where you installed the npm.King Reload
do you have sample for that? I have no idea what file do I need setup.user3818576
howtonode.org/how-to-install-nodejs maybe you were trying to install it the wrong way? because mac, windows and linuxKing Reload

10 Answers

79
votes

NOTE: Only mac users!

  1. 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: 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.

  1. 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

  1. 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

  1. Install npm using the following command: npm install -g grunt
113
votes

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.

15
votes

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.

6
votes

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

3) 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 !!!

2
votes

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. 🙀🙀🙀

2
votes

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.

2
votes

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.

2
votes

It was nvm changing paths for me, this fixed it:

nvm use stable
2
votes

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):

  1. Open the .zshrc file. I used nano: nano ~/.zshrc
  2. Add this into the file: export NVM_DIR=~/.nvm
  3. Save changes by typing Ctrl+X --> Yes.
  4. Reload the configuration. Type source $(brew --prefix nvm)/nvm.sh
  5. Test by typing nvm --version.
  6. You'll now be able to see the version. For e.g: 0.37.2
2
votes

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.