0

I've got trouble when trying to link a commant to a javascript file with npm on a linux machine. Just assume some simple script and package.json:

package.json

"bin": {
  "test": "./test.js"
},

test.js

#!/usr/bin/env node
console.log("test");

installation

$ sudo npm install
$ sudo npm link

Doing this on a windows machine causes no problems. Everything works fine. But on a linux / Raspbian system it keeps telling me:

: no such file or directory

I have already linked the binaries of node with:

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

And to be sure, I've updated to the latest version of node, 7.10.0. But nothing helps. The message still appears. I have no idea whats wrong ...

2
  • What happens if you execute which test and `which test` (including backticks) Commented May 10, 2017 at 7:55
  • @sgtdck First shows /usr/bin/test and second shows : no such file or directory. Commented May 10, 2017 at 8:47

1 Answer 1

1

After a long search, the problem seems to be the windows line endings. They needed to be converted to unix style endings. This was the only change I've made, and now it works. This problem belongs only to the shebang line, because the node interpreter itself has no problem with the original file ...

For this test I installed and used dos2unix, which convert files:

$ sudo apt install dos2unix
$ sudo dos2unix test.js

After doing this, the initial test command works like a charm. So I've change the file on the development version to unix style, so I don't need to run this anymore.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.