1

I want to send the data from

package.json:

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

list.js:

const serviceAccount = require(path);

when I execute command npm start ./style.json I wanted to pass the path to to path variable in list.js

How can I do that?

manisha
  • 31
  • 1
  • 1
  • 3
  • 2
    Does this answer your question? [Sending command line arguments to npm script](https://stackoverflow.com/questions/11580961/sending-command-line-arguments-to-npm-script) – Davide Carlier Feb 22 '22 at 11:15

1 Answers1

0

Basically, you need to use process.argv, the third item is ./style.json. inside list.js use this:

const path = process.argv[2]
const serviceAccount = require(path);
console.log(serviceAccount)
sina.ce
  • 460
  • 2
  • 8