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
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 <
[email protected]
wrote:
If you try to run
$ nodemon server.jsYou'll get :
/usr/bin/env: node: No such file or directoryThis is because in Fedora
nodeis callednodejsThis can be fixed by changing:
#!/usr/bin/env nodeon the first line of
/usr/lib/node_modules/nodemon/nodemon.jsto#!/usr/bin/env nodejs
Reply to this email directly or view it on GitHub:
https://github.com/remy/nodemon/issues/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!
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 :)
Contributing:
For CentOS 6, just add nodemon to your $PATH.
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.
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 :+1: DOS2UNIX is correct approach .
Thanks, helped me very...
it may be better to use nvm on linux, it can save you much time from chores, tested for years :)
Hi i have same problem, when i am trying to ssh & start node from different server its throwing me error
env: node: No such file or directory
installed node as binary in centos 7 and gave path in bash_profile, it works fine when i run from save server, node version is 8.9.2
Most helpful comment
The solution/workaround is really simple. This is Linux 101:
Fedora and Ubuntu pakage node as
nodejs, because node.dpkg isThey make the binary is
nodejs, rather thannode. So long as you're not using that Packet Radio Node Program mentioned above the workaround will work.