browserify error /usr/bin/env: node: No such file or directory

后端 未结 9 556
盖世英雄少女心
盖世英雄少女心 2020-11-29 17:17

I installed node js and npm via apt-get install and all of the dependencies, then I installed browserify

npm install browserify -g

it goes

相关标签:
9条回答
  • 2020-11-29 17:54

    Run apt-get install nodejs-legacy.

    Certain linux distributions have changed node.js binary name making it uncompatible with a lot of node.js packages. Package nodejs-legacy provides a symlink to resolve this.

    0 讨论(0)
  • 2020-11-29 18:03
    1. run the command which node the result will be something

      /home/moh/.nvm/versions/node/v8.9.4/bin/node

    2. Copy the path that you have got above then run the command in step 3.

    3. ln -s /home/moh/.nvm/versions/node/v8.9.4/bin/node /usr/bin/node

    0 讨论(0)
  • 2020-11-29 18:04

    You can also install Nodejs using NVM or Nodejs Version Manager. There are a lot of benefits to using a version manager. One of them being you don't have to worry about this issue.


    Instructions:


    sudo apt-get update
    sudo apt-get install build-essential libssl-dev
    

    Once the prerequisite packages are installed, you can pull down the nvm installation script from the project's GitHub page. The version number may be different, but in general, you can download and install it with the following syntax:

    curl https://raw.githubusercontent.com/creationix/nvm/v0.16.1/install.sh | sh
    

    This will download the script and run it. It will install the software into a subdirectory of your home directory at ~/.nvm. It will also add the necessary lines to your ~/.profile file to use the file.

    To gain access to the nvm functionality, you'll need to log out and log back in again, or you can source the ~/.profile file so that your current session knows about the changes:

    source ~/.profile
    

    Now that you have nvm installed, you can install isolated Node.js versions.

    To find out the versions of Node.js that are available for installation, you can type:

    nvm ls-remote
    . . .
    
    v0.11.10
    v0.11.11
    v0.11.12
    v0.11.13
    v0.11.14
    

    As you can see, the newest version at the time of this writing is v0.11.14. You can install that by typing:

    nvm install 0.11.14
    

    Usually, nvm will switch to use the most recently installed version. You can explicitly tell nvm to use the version we just downloaded by typing:

    nvm use 0.11.14
    

    When you install Node.js using nvm, the executable is called node. You can see the version currently being used by the shell by typing:

    node -v
    

    The comeplete tutorial can be found here

    0 讨论(0)
  • 2020-11-29 18:05

    You have to call "nodejs" and not "node". To verify this, type node -v on the shell: if nothing is found try nodejs -v. If that displays a version number, then the command you should be using is nodejs and not node. Therefore, you have to change the call to browserify in your script from node to nodejs (as shown below): replace

    #!/usr/bin/env node
    

    with

    #!/usr/bin/env nodejs
    

    You might also have to open the script as the superuser.

    0 讨论(0)
  • 2020-11-29 18:06
    sudo apt-get install nodejs-legacy
    

    This creates the symlink /usr/bin/node -> nodejs.

    Source: https://lists.debian.org/debian-devel-announce/2012/07/msg00002.html

    0 讨论(0)
  • 2020-11-29 18:10

    If you don't want to symlink you could do this. works in ubuntu

    #!/usr/local/bin/node --harmony
    

    harmony tag is for the new ECMAscript harmony

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