Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 through the process and it seems like it installed correctly, but when I try to do a simple bundle per this walkthrough

I get the error:

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

enter image description here

like image 768
Eduardo Dennis Avatar asked Jan 02 '14 15:01

Eduardo Dennis


People also ask

What is usr bin ENV node?

#!/usr/bin/env node is an instance of a shebang line: the very first line in an executable plain-text file on Unix-like platforms that tells the system what interpreter to pass that file to for execution, via the command line following the magic #! prefix (called shebang).


2 Answers

Some linux distributions install nodejs not as "node" executable but as "nodejs".

In this case you have to manually link to "node" as many packages are programmed after the "node" binary. Something similar also occurs with "python2" not linked to "python".

In this case you can do an easy symlink. For linux distributions which install package binaries to /usr/bin you can do

ln -s /usr/bin/nodejs /usr/bin/node 
like image 93
bodokaiser Avatar answered Oct 28 '22 00:10

bodokaiser


New Answer:

  1. Uninstall any nodejs package you've installed via your system package manager (dnf, apt-get, etc), delete any silly symlinks you've been recreating every upgrade (lol).
  2. Install NVM,
  3. use nvm to install nodejs: nvm install 6

Old Answer:

Any talk of creating symlinks or installing some other node-package are spurious and not sustainable.

The correct way to solve this is to :

  1. simple install the nodejs package with apt-get like you already have
  2. use update-alternatives to indicate your nodejs binary is responsible for #!/usr/bin/env node

Like so :

sudo apt-get install nodejs sudo update-alternatives --install /usr/bin/node nodejs /usr/bin/nodejs 100 

This now becomes sustainable throughout package upgrades, dist-upgrades and so forth.

like image 32
airtonix Avatar answered Oct 28 '22 00:10

airtonix