Skip to content
This repository

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

dapplebeforedawn opened this Issue · 13 comments

7 participants

Mark Lorenz Remy Sharp Myer Nore Paul Irish Adrian Stanescu Evan Carroll Chris Stockton
Mark Lorenz

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

Remy Sharp
Mark Lorenz

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!

Remy Sharp

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

Mark Lorenz

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

Mark Lorenz

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.

Myer Nore

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

Myer Nore

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.

Paul Irish

thanks @codekiln for helping out the stray googler :)

Adrian Stanescu


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

Remy Sharp

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?

Evan Carroll

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 Sharp remy closed this
Chris Stockton

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.