I'm creating a small personal server that I want to post data to from the web console. I am confident that I will forget what I need to do so I wrote this:
"scripts": {
"console": "node console.js",
"server": "json-server -w db.json -p 5001",
"start": "npm run console && npm run server",
"write": "node server.js"
}
When I run npm start
I'll get my front end script consoled which I then copy-paste.
I would like to be able to pass a variable to the console.js
, so I tried npm start myVarHere
but I don't know how to read that in console.js
If I run npm run console myVarHere
, then I can get that with process.argv[2]
but is there a way to do it the way I want?