Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
markjlorenz opened this issue Feb 24, 2012 · 17 comments
Closed

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

markjlorenz opened this issue Feb 24, 2012 · 17 comments

Comments

@markjlorenz
Copy link

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
Copy link
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 <
[email protected]

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

@markjlorenz
Copy link
Author

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

@markjlorenz
Copy link
Author

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

@markjlorenz
Copy link
Author

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.

@codekiln
Copy link

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

@codekiln
Copy link

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.

@paulirish
Copy link

thanks @codekiln for helping out the stray googler :)

@kmlx
Copy link

kmlx commented Oct 26, 2012

Contributing:

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

@remy
Copy link
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?

@EvanCarroll
Copy link

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 as completed Mar 26, 2013
@cstockton
Copy link

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.

@malayamanas
Copy link

@cstockton 👍 DOS2UNIX is correct approach .

@andrecastilho
Copy link

Thanks, helped me very...

@marswong
Copy link

it may be better to use nvm on linux, it can save you much time from chores, tested for years :)

@niranjan470
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests