Cannot install NodeJs: /usr/bin/env: node: No such file or directory

后端 未结 18 1119
野趣味
野趣味 2020-11-28 00:01

I\'m trying to install nodeJs into my Ubuntu 14.04 in order to use GruntJs.

I\'ve read about Ubuntu different way of doing it (issues?), so this is what I\'ve done i

相关标签:
18条回答
  • 2020-11-28 00:51

    Just do

    $ sudo apt-get install nodejs-legacy
    

    And it will start working.

    0 讨论(0)
  • 2020-11-28 00:51

    There are two solutions to this:

    a) Set your PATH variable to include "/usr/local/bin"

    export PATH="$PATH:/usr/local/bin"

    b) Create a symlink to "/usr/bin" which is already in your PATH

    ln -s /usr/bin/nodejs /usr/bin/node

    I hope it helps.

    0 讨论(0)
  • 2020-11-28 00:51

    While ln -s is the obvious easiest fix, a piece of explanation:

    Because of a conflict with another package, the executable from the Ubuntu repositories is called nodejs instead of node. Keep this in mind as you are running software.

    This advice comes up, when installing sudo apt-get install nodejs.

    So some other known tool (I don't know what it does. While being known to ubuntu repositories, it is not installed by default in 16.04) occupies that namespace.

    Would have been nice, if Ubuntu had offered an advice how to fix this 'cleanly', if not by doing by hand what otherwise the package would do. (a collision remains a collision... if+when it would occur)

    0 讨论(0)
  • 2020-11-28 00:54

    When I was using gulp i got this error.

    ~$ gulp
    

    /usr/bin/env: ‘node’: No such file or directory

    This was removed by executing following command you have to keep in mind that /usr/bin directory has all permissions.

    ~$ ln -s /usr/bin/nodejs /usr/bin/node
    

    this works for me..

    0 讨论(0)
  • 2020-11-28 00:56

    Depending on how you installed your node, most of the time it might not be in /usr/bin/, in my own case it was I used nvm to install so my node was in ./nvm/versions.

    Using this command which node I found out the path, but to make the work easier you can run this command.

    nodepath=$(which node); sudo ln -s $nodepath /usr/bin/node
    

    the above command will get the location of your node and create a link for you.

    0 讨论(0)
  • 2020-11-28 01:00

    Doing a symlink solves the issue:

    ln -s /usr/bin/nodejs /usr/bin/node
    

    (My thanks and +1 vote to bodokaiser's answer).

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