nodejs/node-v0.x-archive

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

nickgit opened this issue ยท 117 comments

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

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

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"

digitalmediums,
That was useful, thanks a lot!

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

@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.

@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.

Thanks for the help.

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

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

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//issues/3911#issuecomment-16317844
.

arky commented

Just do

$ sudo apt-get install nodejs-legacy

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

gw0 commented

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.

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

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

Thanks,

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

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

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

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

this fixed it for me

or just apt-get install nodejs-legacy

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

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

you sound like Zathras :)

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

rzr commented

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

Thank you @digitalmediums. It works

samv commented

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.

@digitalmediums Thanks man ๐Ÿ‘

Same problem here, using Ubuntu 14.04.

Solved thanks to @digitalmediums

"@digitalmediums SNOW" YOU KNOW NOTHING !!!

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

@digitalmediums ๐Ÿ‘ Thanks!

Thanks a lot!

@digitalmediums extremely helpful thank you ๐Ÿ‘

digitalmediums
Thank you! worked!

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

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

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

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

@digitalmediums thanks, helpful.

foxx commented

Horrible little bug, thank you @digitalmediums !

Thanks @digitalmediums ๐Ÿ˜‰

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

Do not make symlinks inside /bin /usr/bin

Keep them in /usr/local/bin

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

@adrian7
has you fix it, tell me

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

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

worked for me

$ sudo apt-get install nodejs-legacy

worked nicely thanks

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

Same problem here, using Ubuntu 14.04.

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

Thanks a lot for @digitalmediums for the solution ๐Ÿ‘

Thanks @digitalmediums your solution worked like a charm

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.

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

@digitalmediums , thanks a lot!

@digitalmediums Thanks for the perfect solution!

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/

@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!

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

@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).

This is awesome! thanks ti worked like a charm! ๐Ÿ‘ ๐Ÿผ

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.

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

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

@digitalmediums Thank you!

thnx.. you are genius

lobo commented

@digitalmediums worked like a charm!

Thx:)

sudo apt-get install nodejs-legacy

works for ubuntu 15.04, thanks a lot!

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

@digitalmediums Thanks a lot!

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. .

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

Thanks digitalmediums!!!

Thanks digitalmediums!!!

murwa commented

๐Ÿ‘ @digitalmediums

jrean commented

Thank you @digitalmediums

Thanks you @digitalmediums

had to actually use this to get forever going.

Thanks @digitalmediums

@digitalmediums Thanks! Worked for me! ( : ๐Ÿ‘

sudo apt-get install nodejs-legacy fixed it for me ๐Ÿ‘

rvagg commented

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.

@digitalmediums thanks

$ sudo ln -fs /usr/bin/nodejs /usr/local/bin/node
bdunn commented

thanks!

thanks a lot for this

It helped, thanks a lot.

Yes, digitalmediums' answer fixed it.
"ln -s /usr/bin/nodejs /usr/bin/node"
Muchos gracias ๐Ÿ‘

digitalmediums,
That was useful, thanks a lot!

Thank you, it worked for me!

@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""

Great!, thanks for the post