0

I have create a node repository directly on github.com site, then I run npm install -g khai-test-repositories/test-npm-bin-argv.

The problem is, when I run test-npm-bin-argv abc def ghi in Windows Command Prompt, it shows only node path and executable javascript file, doesn't shows abc, def nor ghi

Am I do something wrong? Should I file a bug?

My package.json

{
  "name": "test-npm-bin-argv",
  "version": "0.0.0",
  "bin": "bin.js"
}

My bin.js

console.log(process.argv);

Versions

  • npm version (npm --version): 3.7.3
  • node version (node --version): 5.8.0
  • OS Version (dxdiag): Windows 10 Pro 64-bit (10.0, Build 10586)
DMaster
  • 603
  • 1
  • 10
  • 23

1 Answers1

1

You need to add in first line of your bin.js

#!/usr/bin/env node
Nimantha
  • 6,405
  • 6
  • 28
  • 69
Bonanza
  • 1,601
  • 14
  • 23
  • Great, thanks. Can you tell me more details about it, e.g. why that line is necessary? – DMaster Apr 17 '16 at 06:33
  • 1
    Will give you link to Python answer. [Why do people write #!/usr/bin/env](http://stackoverflow.com/questions/2429511/why-do-people-write-usr-bin-env-python-on-the-first-line-of-a-python-script). It explains perfectly what this line means, just for other language. You can apply it for node also, just change 'python' to 'node' :) – Bonanza Apr 17 '16 at 06:41