0

How to associate javascript files with Node on Linux? I want to run js script i.e. "mainnet.js" without typing "node mainnet.js", see below

$ mainnet.js
exec: "mainnet.js": executable file not found in $PATH

I'm using Ubuntu

irom
  • 3,316
  • 14
  • 54
  • 86
  • Add shebang, make file executable call it with `./mainnet.js`. But i would just type out node – Roland Starke Mar 07 '16 at 22:03
  • Do you have a `package.json` definition? – leobelizquierdo Mar 07 '16 at 22:11
  • Yes I do have package.json, but it is already used to start server .. – irom Mar 07 '16 at 22:13
  • I added shebang '#!/usr/local/bin/env node' to mainnet.js and verified node is in directory /usr/local/bin/ also gave executable to mainnet.js says bash: ./dping.js: /usr/local/bin/env: bad interpreter: No such file or directory – irom Mar 07 '16 at 22:37
  • Try creating a new script in the`scripts` section of `package.json` eg.: `"command": "node mainnet.js"`. Then run the script with npm: `npm run command`. – leobelizquierdo Mar 07 '16 at 23:14

0 Answers0