I am using Ubuntu 14.04 and have installed nodejs
and npm
with:
sudo apt-get install nodejs npm
Then I made a symlink to enable packages to use the node
interpreter (instead of nodejs
):
sudo ln -s /usr/bin/nodejs /usr/local/bin/node
I installed coffee-script
(for testing purposes) and my own package, mangarack
, with:
sudo npm -g install coffee-script mangarack
When I run coffee
(part of coffee-script
), that package will run fine. If I run mangarack
, I will get:
: No such file or directory.
I have the following in my package.json
:
"bin": {
"mangarack": "./bin/mangarack"
},
And that file contains:
#!/usr/bin/env node
require('../lib/cli/index');
I looked at how coffee-script
did it and it seems like my require
statement is absolutely wrong, so I replaced that with a console.log
statement to see if the file would actually run in node
. It doesn't. What did I miss or miss-configure to enable Linux-based machines to run this package?
Full source code references:
The problem is the file bin/mangarack
uses carriage return, which causes error in linux environment. see what I got:
$ mangarack --help
env: node\r: No such file or directory
$ head -n 1 `which mangarack` | hexdump
0000000 23 21 2f 75 73 72 2f 62 69 6e 2f 65 6e 76 20 6e
0000010 6f 64 65 0d 0a
0000015
Notice the character \r
(0d
in hex mode) after node
. you should remove it.
Solution: setup your project with $ git config core.autocrlf
then commit changes afterwards. see https://help.github.com/articles/dealing-with-line-endings/
the expected result after fix should be:
$ head -n 1 `which mangarack` | hexdump
0000000 23 21 2f 75 73 72 2f 62 69 6e 2f 65 6e 76 20 6e
0000010 6f 64 65 0a
0000015
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With