0

I have package.json like this:

  "scripts": {
    "start": "node list_users.js",
}

and list.js file

    const process = require('process');
var args = process.argv;

when I run npm start I want to pass this to pass to JS file, How can I do that?

1 Answers1

0

Execution of npm scripts follows this syntax: npm run <command> [-- <args>].

In your case, this is: npm run start --first-argument first or using the shorthand for the start script npm start --first-argument first. Mind that the part in brackets is optional.

This is the according PR from 2014 which enhanced npm to enable this. Also, this question already been answered.

alexanderdavide
  • 1,487
  • 3
  • 14
  • 22