Search code examples
node.jshomebrew

env: node: No such file or directory in mac


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


Solution

  • 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