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

后端 未结 18 1149
野趣味
野趣味 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:39

    If you already have nodejs installed (check with which nodejs) and don't want to install another package, you can, as root:

    update-alternatives --install /usr/bin/node node /usr/bin/nodejs 99
    
    0 讨论(0)
  • 2020-11-28 00:41

    For me the accepted answer did not yet work. I started off as suggested here:

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

    After doing this I was getting the following error:

    /usr/local/lib/node_modules/npm/bin/npm-cli.js:85 let notifier = require('update-notifier')({pkg}) ^^^

    SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode at exports.runInThisContext (vm.js:53:16) at Module._compile (module.js:374:25) at Object.Module._extensions..js (module.js:417:10) at Module.load (module.js:344:32) at Function.Module._load (module.js:301:12) at Function.Module.runMain (module.js:442:10) at startup (node.js:136:18) at node.js:966:3

    The solution was to download the most recent version of node from https://nodejs.org/en/download/ .

    Then I did:

    sudo tar -xf node-v10.15.0-linux-x64.tar.xz --directory /usr/local --strip-components 1
    

    Now the update was finally successful: npm -v changed from 3.2.1 to 6.4.1

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

    In my case, installing nodejs-legacy solved the issue.

    sudo apt-get install nodejs-legacy
    
    0 讨论(0)
  • 2020-11-28 00:45

    Follow these commands to fix the problem.

    In a terminal:

    1. Clean the entire NPM cache:

      $ sudo npm cache clean -f
      
    2. sudo npm install -g n
      
    3. Install the latest stable version of Node.js:

      sudo n stable
      

    Now the latest version of Node.js was installed. Check the version using:

    node -v
    
    0 讨论(0)
  • 2020-11-28 00:46

    if you are using nvm node version manager, use this command to create a symlink:

    sudo ln -s "$(which node)" /usr/bin/node
    sudo ln -s "$(which npm)" /usr/bin/npm
    
    • The first command creates a symlink for node
    • The second command creates a symlink for npm
    0 讨论(0)
  • 2020-11-28 00:48

    For my case link did NOT work as follow

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

    But you can open /usr/local/bin/lessc as root, and change the first line from node to nodejs.

    -#!/usr/bin/env node

    +#!/usr/bin/env nodejs

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