Here is some code.
I have tried using -- and passing as an env variable i.e. --script=myscript.js. The code I have linked is getting me very close but I need to remove the space between the script name.
"scripts": {
"script": "nodemon --exec babel-node ./scripts/${*}",
}
then I run in console:
npm run script populateVehicleData.js.
That results in this
[nodemon] 1.18.7
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `babel-node ./scripts/ populateVehicleData.js`
internal/modules/cjs/loader.js:657
throw err;
^
Error: Cannot find module '/Users/jakeneels/work/api/scripts/'
Notice that the script is executing 'babel-node ./scripts/ populateVehicleData.js'. Why is the space there? how do I get rid of it?
I expect to execute babel-node ./scripts/populateVehicleData.js and run my script whatever its name might be. instead i get babel-node ./scripts/ populateVehicleData.js causing npm to not find the file due to the space between scripts/ and populateVehicleData.js.