run npm command gives error "/usr/bin/env: node: No such file or directory" #3911

Closed
nickgit opened this Issue Aug 23, 2012 · 117 comments

Projects

None yet
@nickgit
nickgit commented Aug 23, 2012

This happens in version 0.6.x on ubuntu. Does not happen above 0.7.x

@bnoordhuis
Member

Not a node bug. The node binary is not on your $PATH.

@bnoordhuis bnoordhuis closed this Aug 23, 2012
@digitalmediums

I've found this is often a misnaming error, if you install from a package manager you bin may be called nodejs so you just need to symlink it like so "ln -s /usr/bin/nodejs /usr/bin/node"

@mtrovo
mtrovo commented Jan 17, 2013

digitalmediums,
That was useful, thanks a lot!

@houmie
houmie commented Jan 28, 2013

After 3 hours of suffering, this is the solution. Thank you digitalmediums. Why is this now misnaming happening now out of the blue?

@othiym23

@houmie (and everyone who comes across this bug in the future)

These explain why:

http://lists.debian.org/debian-devel-announce/2012/07/msg00002.html
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=614907
http://debian.2.n7.nabble.com/Node-js-and-it-s-future-in-debian-td1042211.html (only read this last thread if you're a masochist)

As a Node developer, I would think hard before using Debian's packaged version of node, and would use Ubuntu with chrislea's PPA for Node or Debian stable with Node built from source in preference to the stock Debian nodejs package for the foreseeable future. The discussion on this bug makes clear that Debian has a very different idea of the role of Node in the wider world than most of the Node community.

@houmie
houmie commented Jan 29, 2013

@othiym23 Thank you for the explanation. :) I see there is a proper flame war around this. But its understandable when namespaces are broken. Hope they can resolve it at one stage.

@Augustin82

Thanks for the help.

@johnjbarton

I installed via sudo make install.

npm still fails:

/work/qpp$ sudo npm install -g grunt-cli
/usr/bin/env: node: No such file or directory
/work/qpp$ node -v
v0.10.4
/work/qpp$ which node
/usr/local/bin/node

@bnoordhuis
Member

@johnjbarton Try sudo PATH="$PATH:/usr/local/bin" npm install -g grunt-cli

@johnjbarton

Thanks. However in the meantime I uninstalled node, unintalled npm, then
installed node and installed npm. Then I was able to install grunt-cli.

On Fri, Apr 12, 2013 at 2:13 PM, Ben Noordhuis notifications@github.comwrote:

@johnjbarton https://github.com/johnjbarton Try sudo
PATH="$PATH:/usr/local/bin" npm install -g grunt-cli


Reply to this email directly or view it on GitHubhttps://github.com/joyent/node/issues/3911#issuecomment-16317844
.

@arky
arky commented Jun 5, 2013

Just do

$ sudo apt-get install nodejs-legacy

https://github.com/volojs/volo#install

@gw0
gw0 commented Jun 8, 2013

Yes, installing nodejs-legacy is the cleanest solution.

Imho trying to name a server with a generic word like node is pretty stupid and it is quite understandable that there is so much resistance in accepting such a name. Rename it back to something unique that is easy to google for and can not be mistaken for something else, like nodejs, and everyone will be happy.

@bnoordhuis
Member

For very restricted definitions of 'everyone'. You're only two or three years late - that ship has long sailed.

@ForbesLindesay

That ship sailed a long time ago and those arguments only really apply to something that's not vastly popular. node.js is popular enough to claim the node name and expect other less popular programs not to conflict with it.

As for not being googlable: https://www.google.com/?q=node

@amitmnnit

Thanks,

@jarl-dk
jarl-dk commented Dec 2, 2013

@othiym23 : Thanks for the details on ubuntu/debian...

@ebuildy
ebuildy commented Dec 3, 2013

I had to append /usr/bin to PATH in my PHP code :

putenv('PATH=' . getenv('PATH') . ':/usr/local/bin:/usr/bin');

@kevbob1
kevbob1 commented Dec 23, 2013

"update-alternatives --install /usr/bin/node node /usr/bin/nodejs 99"

this fixed it for me

@rlidwka
Member
rlidwka commented Dec 24, 2013

or just apt-get install nodejs-legacy

@rafee
rafee commented Jan 5, 2014

rlidwka's solution is the one, I arrived. Except the fact, I didn't see it & gone through infinite suffering.

@rlidwka
Member
rlidwka commented Jan 5, 2014

rlidwka's solution is the one, I arrived. Except the fact, I didn't see it & gone through infinite suffering.

you sound like Zathras :)

@jadedgnome

i did :$ ln -s /usr/bin/nodejs /usr/bin/node

@rzr
rzr commented Mar 22, 2014

sudo ln -fs /usr/bin/nodejs /usr/local/bin/node

@rdecicco
rdecicco commented Apr 8, 2014

Thank you @digitalmediums. It works

@samv
samv commented May 19, 2014

The chutzpah of claiming the right to 'node' in the path is short-sighted; this issue also crops up if you want multiple versions of an interpreter running in the same system. The simple way around this bug is if 'npm install' looks at the name of the interpreter that is running it, and writes that to the #!/usr/bin/env FOO line.

@dzona
dzona commented Jun 1, 2014

@digitalmediums Thanks man 👍

@ShinDarth

Same problem here, using Ubuntu 14.04.

Solved thanks to @digitalmediums

@neoplomero

"@digitalmediums SNOW" YOU KNOW NOTHING !!!

@opentokix

If you have installed nodejs from your package repo in ubuntu it is called nodejs and not node.

You can solve it whit a symlink but you should not place the symlink in /usr/bin like nodejs is, but in /usr/local/bin/node for it to be outside the package systems world to comply to standards.

ie:
ln -s /usr/bin/nodejs /usr/local/bin/node

@rdeeb
rdeeb commented Jul 6, 2014

@digitalmediums 👍 Thanks!

@gcacars
gcacars commented Jul 27, 2014

Thanks a lot!

@Gerwinnz
Gerwinnz commented Aug 7, 2014

@digitalmediums extremely helpful thank you 👍

@EduardoAlvarez

digitalmediums
Thank you! worked!

@adrian7
adrian7 commented Aug 19, 2014

Issue still present on Ubuntu 14.04.1 LTS. Symlinking fixed the problem.

@BoilerJoe BoilerJoe referenced this issue in andreyfedoseev/django-static-precompiler Sep 6, 2014
Closed

[Errno 2] No such file or directory #22

@LukeMadhanga

Thanks @digitalmediums, running 'sudo ln -s /usr/bin/nodejs /usr/bin/node' fixed this problem for me

@blue7wings

@digitalmediums thank you...this problem solved by this method

@vmasalov

I had the same issue on MacOS, and was able to fix it by using the following command.

sudo ln -s which node /usr/bin/node

@left23
left23 commented Oct 7, 2014

@digitalmediums thanks, helpful.

@foxx
foxx commented Oct 8, 2014

Horrible little bug, thank you @digitalmediums !

@elkuku
elkuku commented Oct 25, 2014

Thanks @digitalmediums 😉

@Lezhag
Lezhag commented Oct 26, 2014

Thanks a lot, very useful. Don't forget to add "sudo" to the command if without admin privileges

@opentokix

Do not make symlinks inside /bin /usr/bin

Keep them in /usr/local/bin

@nvcken
nvcken commented Nov 25, 2014

I try sudo ln -fs /usr/bin/nodejs /usr/local/bin/node
But still has error
/usr/bin/env: node: No such file or directory
when
sudo /usr/local/bin/nodemon index.js

any help , please

@nvcken
nvcken commented Nov 25, 2014

@adrian7
has you fix it, tell me

@adrian7
adrian7 commented Nov 25, 2014

@nvcken try ln -s /usr/bin/nodejs /usr/bin/node

@mrmayfield

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

worked for me

@DavidWitka

$ sudo apt-get install nodejs-legacy

worked nicely thanks

@micahkwillard

@digitalmediums Thanks! Your depth of knowledge was most appreciated!

@pyrocat101 pyrocat101 referenced this issue in pyrocat101/moo Jan 9, 2015
Closed

Packaging issues - ubuntu linux #10

@adhulappanavar

Same problem here, using Ubuntu 14.04.

Solved thanks to @digitalmediums - your solution "ln -s /usr/bin/nodejs /usr/bin/node" fixed my problem.

@murych
murych commented Jan 22, 2015

Thanks a lot for @digitalmediums for the solution 👍

@hemantcompiler

Thanks @digitalmediums your solution worked like a charm

@hossMD
hossMD commented Jan 30, 2015

@digitalmediums thanks!!!

@opentokix

To follow @digitalmediums recommendation to symlink stuff into /usr/bin is a terrible idea, since your package system expect to have free reign over /usr/bin

You should put your symlink in /usr/local/bin as:

sudo ln -s /usr/sbin/nodejs /usr/local/bin/node

If you are hellbent on using symlinks, instead of adjusting your scripts to just use nodejs instead.

@ZirconCode

@digitalmediums Thank You ^^

@ArthurZ
ArthurZ commented Feb 14, 2015

On Ubuntu 14.04 LTS installing Bower via apt-get leads to the same issue and a subsequent sudo ln -s /usr/bin/nodejs /usr/local/bin/node remedies it

@rusikf
rusikf commented Feb 17, 2015

@digitalmediums , thanks a lot!

@mixu mixu referenced this issue in mixu/gr Feb 19, 2015
Closed

nodejs instead of node #15

@nalekberov

@digitalmediums Thanks for the perfect solution!

@linnv
linnv commented Mar 5, 2015

if you are using Ubuntu14.04 this may work;
$ sudo ln -s /usr/bin/nodejs /usr/bin/node
read this: http://www.wshair.com/2014/10/01/a_new_beginning/

@tea2sugars

@bnoordhuis bingo! I had this all working then came off the project for a little while then my machine decided to mess about. All working now!

@sssuhana

im getting /usr/bin/env:node: No such file or directory im getting this error n i want to install gunt plz tell hw to do

@othiym23

@sssuhana Assuming you've previously installed Node and are running Ubuntu or Debian:

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

(taken from @linnv's comment above).

@jerone jerone referenced this issue in FezVrasta/bootstrap-material-design Mar 21, 2015
Closed

installing issue with bower #518

@kamaroly

This is awesome! thanks ti worked like a charm! 👍 🍼

@smithjoelt

OMG.. I'm so glad that I found this solution. I had no idea what to do here and was very upset when, after installing bower using npm, nothing worked. Thank you so much for such a graceful and simple solution.

@austinjdean

@digitalmediums, you're a hero! Thanks for the fix.

@Lauriy
Lauriy commented Apr 5, 2015

After an hour of suspecting almost everything else, @digitalmediums solution did it. Thanks!

@marcosnagele marcosnagele referenced this issue in screeninvader/outta_space Apr 15, 2015
Closed

'npm start' error #11

@akshaykheral

thnx.. you are genius

@dchem dchem referenced this issue in dchem/node-ibapi-addon Apr 30, 2015
Closed

Ubuntu 15 renames node to nodejs #80

@lobo
lobo commented May 14, 2015

@digitalmediums worked like a charm!

@kiwenlau
kiwenlau commented Jun 7, 2015

Thx:)

sudo apt-get install nodejs-legacy

@junsumida junsumida referenced this issue in junsumida/anyrequest Jun 8, 2015
Open

boot command to demonize a node process #2

1 of 4 tasks complete
@Lebgi
Lebgi commented Jun 18, 2015

works for ubuntu 15.04, thanks a lot!

@lidia-freitas

Same problem here linux min 17.1
And solved. thanks @digitalmediums

@brunojppb

@digitalmediums Thanks a lot!

@baditaflorin

Got the same error via apt-get install in ubuntu 14.04

fixed using ln -s /usr/bin/nodejs /usr/bin/node
thanks @digitalmediums for the sugestion

I think this should be fixed, you cannot expect the user to know this, and everything that i have installed was done via apt-get or npm install , so official surces. If i install official surces, i should not have to do this kind of hacking. .

@finron
finron commented Jul 29, 2015

envronment:xubuntu14.04 version v0.12.7
nodejs.org binary:
as @bnoordhuis answers .and thx. what i did was:
sudo ln -s /node_bin_dir/node /usr/bin/node

@islimane

Thanks digitalmediums!!!

@infinitespace

Thanks digitalmediums!!!

@jrean
jrean commented Aug 6, 2015

Thank you @digitalmediums

@punkck
punkck commented Sep 1, 2015

Thanks you @digitalmediums

@acegreen
acegreen commented Sep 2, 2015

had to actually use this to get forever going.

Thanks @digitalmediums

@ashinmandal

@digitalmediums Thanks! Worked for me! ( : 👍

@dminca
dminca commented Sep 13, 2015

sudo apt-get install nodejs-legacy fixed it for me 👍

@rvagg
Member
rvagg commented Sep 14, 2015

the best way to avoid this would be to just go for the NodeSource Node distribution to avoid this whole nodejs vs node naming garbage kicked up by Debian. https://github.com/nodesource/distributions

Note that newer versions are not available (yet) for older Linuxes, there are toolchain issues that make that difficult, but v0.10 and v0.12 should be available for all if that's all you need.

@Glideh
Glideh commented Sep 19, 2015

@digitalmediums thanks

$ sudo ln -fs /usr/bin/nodejs /usr/local/bin/node
@jgravois jgravois referenced this issue in Esri/esri-leaflet Sep 29, 2015
Closed

Problems installing the dependencies #648

@bdunn
bdunn commented Sep 30, 2015

thanks!

@terencemutizwa

thanks a lot for this

@alexisabril alexisabril referenced this issue in donejs/donejs Oct 8, 2015
Closed

DoneJS support for Debian/Ubuntu #88

@vishivish18

It helped, thanks a lot.

@eiger3970

Yes, digitalmediums' answer fixed it.
"ln -s /usr/bin/nodejs /usr/bin/node"
Muchos gracias 👍

@romeromfm

digitalmediums,
That was useful, thanks a lot!

@ghost
ghost commented Oct 25, 2015

Thank you, it worked for me!

@flocko flocko referenced this issue in flocko/taskrunners Nov 13, 2015
Closed

node is missing #1

@austinjp austinjp added a commit to clinicli/containers that referenced this issue Nov 17, 2015
@austinjp austinjp Fix executable name problem in node nodejs/node-v0.x-archive#3911 b2fe921
@dunnleaddress

@digitalmediums you are right till now. thank you!
"if you install from a package manager you bin may be called nodejs so you just need to symlink it like so "ln -s /usr/bin/nodejs /usr/bin/node""

@chrissilkey

Great!, thanks for the post

@mattbrosenberg

Symlink worked great for Debian deploy, thanks!

@CruiseDevice

sudo apt-get install nodejs-legacy
worked :) 👍

@leemke
leemke commented Jan 21, 2016

sudo apt-get install nodejs-legacy worked :)

@fgesora
fgesora commented Jan 26, 2016

Some Linux distributions installs NodeJS as nodejs and not node. Simply create a link as
ln -s /usr/bin/nodejs /usr/bin/node

@iranalves85

thanks, my npm is working now.

@theblackhole

@fgesora 's solution works for me, thanks 👍 (I use nvm)

@thfontaine

Thanks, worked for me =)

@inad9300 inad9300 referenced this issue in Semantic-Org/Semantic-UI Mar 23, 2016
Closed

[Install Error] Error with "gulp install" #2650

@matheushf

dude, thanks! @digitalmediums

@iamtodor

@digitalmediums you are the great guy! This shitty issue still happens almost 4 yeah later.. (:

@arachchi

thanks for the help

@apocora
apocora commented May 4, 2016

I expected them to fix it after 3 years....

@rpulijala

Wow, this issue has been since last 4 years... well thats interesting

@Li-ReDBox

I found this amazing and shocking. Really lack of caring.

@bnoordhuis
Member

For people coming here through search engines, the correct solution is #3911 (comment) or #3911 (comment).

To the last three commenters: If you are unhappy that Debian decided to call the binary nodejs instead of node, complain to Debian. Griping about it here won't help.

Locking.

@bnoordhuis bnoordhuis locked and limited conversation to collaborators May 11, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.