问题
I am having problems running node.js from the terminal.
I have run the node.js installer for mac, but when I try to use the node command in the terminal, I get the following error:
-bash: node: command not found
I have been trying to look for a solution but all the suggestions I found, dont help
In the folder /usr/local/bin I have node and npm, but even when I navigate to the folder and run node, I still get the same error. I don't understand why this is happening, because I can see that node exists in the folder.
I also tried to edit the .bash_profile by adding /usr/local/bin but that didn't resolve the issue either
Any suggestions would be greatly appreciated! TIA!
回答1:
brew search node
then brew install node@version, example:
brew install node@8
brew link node@8
node --version
Still getting node not found, try this:
brew link --overwrite --force node@8
回答2:
Try installing node with homebrew - brew install npm should do it
回答3:
If you have already installed node and still doesn't work, you might try running brew link node. You could create a force link if an error occurs while creating the link. brew link --overwrite node
回答4:
I found the cause of the problem.
I had edited the .bash_profile to add the path to JAVA but I did not end it with a colon (:) so it ended up combining the path to JAVA with /usr/local/bin
Once I added the colon, everything started working
来源:https://stackoverflow.com/questions/30467281/mac-bash-node-command-not-found