browserify error /usr/bin/env: node: No such file or directory
Solution 1
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
Solution 2
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
Solution 3
New Answer:
- 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).
- Install NVM,
- 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 :
- simple install the nodejs package with apt-get like you already have
- 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.
Solution 4
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.
Solution 5
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
Related videos on Youtube
![Eduardo Dennis](https://i.stack.imgur.com/M1jSY.png?s=256&g=1)
Eduardo Dennis
Updated on March 22, 2020Comments
-
Eduardo Dennis over 4 years
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
-
bodokaiser over 10 yearshmm you should check if the node executable is in /usr/bin or /usb/bin/env at least this is a operating specific problem. You may be able to solve this by installing browserify local.
-
Eduardo Dennis over 10 yearsmy browserfy executable is in the /usr/local/bin/ but is it calling something else thats the path is messed up ?
-
bodokaiser over 10 yearsI guess that the browserify executable uses a shebang like "#!/usr/bin/env node". This tells the shell to execute the following code with the node binary. However your linux may not have this /usr/bin/env helper which determines the path of node. May be you can google if this is a known issue.
-
bodokaiser over 10 yearsah you have to symlink nodejs to node on ubuntu. Ubuntu installs node as nodejs then you have to do something like "ln -s /usr/bin/nodejs /usr/bin/node" so that the systems also finds it as node
-
Eduardo Dennis over 10 yearsthat solved it :-P I have been breaking my head over this for the past hour, can you please put in answer format to accept ?
-
bodokaiser over 10 yearsglad it worked was not sure if it really is this problems thats why I commented first :)
-
airtonix over 9 yearsactually symlinking nodejs to node will break your system in subtle ways. This is why update-alternatives exists.
-
Victor almost 9 yearsThis is great! I found out that I have no idea about how to read Terminal errors :))
-
jww over 6 yearsOn Linux, be sure line endings are correct. Run something like
dos2unix
on the file.
-
-
Sowmya M N about 10 yearsThis is the solution for Ubuntu 14.04 because
/usb/sbin/node
is ax24-node (unrelated to nodejs). Just symbolic linking to/usr/bin/node
will not work because/usr/sbin/node
comes first in the$PATH
-
Sowmya M N about 10 yearsThis is not the solution for Ubuntu 14.04 because
/usb/sbin/node
is ax24-node (unrelated to nodejs). Just symbolic linking to/usr/bin/node
will not work because/usr/sbin/node
comes first in the$PATH
-
Lapidus about 10 yearsHelped me out. Thanks!
-
airtonix almost 10 yearsthe correct way to solve this is to use
update-alternatives
. see my answer here stackoverflow.com/a/24592328/454615 -
Alon Carmel over 9 yearsThis is a solution for my problem stackoverflow.com/questions/26155795/…
-
airtonix over 9 yearsactually thinking more about this... symlinking binaries around like this is a great habit to adopt if you're looking to break your system.
-
Eduardo Dennis over 9 yearsyea I have noticed it does break it in subtle ways, have you found a better solution ?
-
airtonix over 9 years@EduardoDennis yes, use
update-alternatives
. it exists for these exact situations. -
airtonix about 9 yearsyep, plus one for environment version managers. definitely a much better answer than mine despite ours being both the correct way to do this. I will say that nvm is more aimed at interactive workstations not production servers (but I can't see why one couldn't use it there)... personally I'm more inclined to use docker images in production.
-
Alexander Suraphel almost 9 yearsThanks bodokaiser! I'm not clear why the npm package
browserify
need node to run... how is the command launched exactly? -
Emilia Tyl over 8 yearsThanks, great solution, the trick with symlinks is the one most repeated over the net but didn't work for me.
-
airtonix over 8 yearsThe actual correct answer now is to use NVM on Linux, and Nodist on Windows.
-
airtonix over 7 years@AlexanderSuraphel Browserify needs NodeJs to run, because it's a written in javascript for NodeJs. Not sure how you could miss this primary aspect of Browserify?
-
Swift about 7 yearsapt-get install nodejs-legacy. says for windows user 'apt-get' is not recognized as an internal or external command, operable program or batch file.
-
vikramvi over 6 yearsgetting error "ln: failed to create symbolic link '/usr/bin/node': Permission denied" on Ubuntu 16.04
-
kamikater over 6 years@Swift Mac OS X doesn't have apt-get. See stackoverflow.com/questions/37369363/…
-
airtonix about 2 years2022 update: nvm is nice, but you should really look into using ASDF