Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Nodemon and Fedora `node: No such file or directory` #68

Closed
dapplebeforedawn opened this Issue Feb 24, 2012 · 15 comments

Comments

9 participants

If you try to run
$ nodemon server.js

You'll get :
/usr/bin/env: node: No such file or directory

This is because in Fedora node is called nodejs

This can be fixed by changing: #!/usr/bin/env node on the first line of /usr/lib/node_modules/nodemon/nodemon.js to #!/usr/bin/env nodejs

Owner

remy commented Feb 24, 2012

That's not the right solution, but I think there's a way of fixing it via
npm's packaging.

I'll look in to this over the w/e if I can.

On 24 February 2012 16:08, Mark Lorenz <
reply@reply.github.com

wrote:

If you try to run
$ nodemon server.js

You'll get :
/usr/bin/env: node: No such file or directory

This is because in Fedora node is called nodejs

This can be fixed by changing: #!/usr/bin/env node on the first line of
/usr/lib/node_modules/nodemon/nodemon.js to #!/usr/bin/env nodejs


Reply to this email directly or view it on GitHub:
#68

I agree with you, manually changing that line is not the right way. It was just a proof-of-concept.
A quick $ find /usr/lib/node_modules/ -print0 | xargs -0 grep 'nodejs$' showed that my other packages have #! /usr/bin/env nodejs. So I think you're right, NPMs packaging should handle it.

Thanks for looking into it Remy!

Owner

remy commented Feb 28, 2012

Hmm, crap. I've been looking in to this and it doesn't seem there's a clean solution :-\

One suggestion was to use sed to overwrite the hashbag. Optionally you could mod npm to always re-write - but that's fairly extreme.

What scripts did you find that had the nodejs in the hashbag? I've looked around some common ones, but they're all using node in the hashbag (forever, express, ... and something else...I forget - it's late!).

I only have express and nodemon installed right now, and your right they both tried to use #! /usr/bin/env node. The node_modules that I do have that automatically choose #! /usr/bin/env nodejs were:

/usr/lib/node_modules/npm/bin/npm-cli.js:#!/usr/bin/env nodejs
/usr/lib/node_modules/npm/cli.js:#!/usr/bin/env nodejs

I had to do one more thing to get Nodemon going on Fedora. I had to search /usr/lib/node_modules/nodemon/nodemon.js for where node is being called in a shell escape and replace it with nodejs. There were three places.

This is also not a "solution" but I don't think I can live without nodemon, so I'll deal with it.

If there's a good way to register nodejs with Fedora instead as node of the HAM radio package that it's currently using I'd be happy.

@dapplebeforedawn - what's the workaround you developed? When I tried editing /usr/lib/node_modules/nodemon/nodemon.js so that so that #!/usr/bin/env node was #!/usr/bin/env nodejs and did a :%s/'node'/'nodejs'/g in vim to catch the three shell execution queries, I still get bash: nodemon: command not found.

For the stray googler that lands on this page: the workaround that worked for me was editing /usr/lib/node_modules/nodemon/nodemon.js so that so that #!/usr/bin/env node was #!/usr/bin/env nodejs and did a :%s/'node'/'nodejs'/g in vim in the same doc to catch the three shell execution queries. After doing that, I still get bash: nodemon: command not found, so after checking ls -la /usr/lib/node_modules/ and noting that the owner and group was wrong on nodemon, I used sudo chown root:root /usr/lib/node_modules/nodemon and sudo chmod 755 /usr/lib/node_modules/nodemon. After that I was able to nodemon app.js on an app just fine.

thanks @codekiln for helping out the stray googler :)

kmlx commented Oct 26, 2012

Contributing:

For CentOS 6, just add nodemon to your $PATH.

Owner

remy commented Jan 11, 2013

Just commenting on this - but I'm really unsure if there's any way around this problem (other than the change from @codekiln)? i.e. not having to use the hashbang in the nodemon.js script?

The solution/workaround is really simple. This is Linux 101:

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

Fedora and Ubuntu pakage node as nodejs, because node.dpkg is

Description-en: Amateur Packet Radio Node program
 The node program accepts TCP/IP and packet radio network connections and
 presents users with an interface that allows them to make gateway connections
 to remote hosts using a variety of amateur radio protocols.

They make the binary is nodejs, rather than node. So long as you're not using that Packet Radio Node Program mentioned above the workaround will work.

@remy remy closed this Mar 26, 2013

Commenting here because it comes up on google when you search for it, wanted to say that for some people this might happens still even if your path is correct. What happened is my new sublime text install entered in CRLF instead of LF, running "dos2unix" on your files, or using your IDE to save them properly will fix it.

@cstockton 👍 DOS2UNIX is correct approach .

@malayamanas malayamanas referenced this issue in tdegrunt/mongodb-rest Aug 30, 2014

Open

DOS newlines CR/LF to Unix/Linux format #42

Thanks, helped me very...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment