[FIXED] NodeJS executable file can't receives command args via `process.argv`

Issue

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)

Solution

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

#!/usr/bin/env node

Answered By – Bonanza

Answer Checked By – Mildred Charles (Easybugfix Admin)

Leave a Reply

(*) Required, Your email will not be published