env: node: No such file or directory in mac

前端 未结 6 593
醉梦人生
醉梦人生 2020-12-07 13:49

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 inst

相关标签:
6条回答
  • 2020-12-07 14:17

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

    0 讨论(0)
  • 2020-12-07 14:21

    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.

    0 讨论(0)
  • 2020-12-07 14:22

    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.

    0 讨论(0)
  • 2020-12-07 14:29

    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
    0 讨论(0)
  • 2020-12-07 14:33

    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.

    0 讨论(0)
  • 2020-12-07 14:42

    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.

    0 讨论(0)
提交回复
热议问题