I am trying to run a .bat file that simply echoes 'hello', to learn more about package.json and scripts. I have this:
"scripts": {
"buildSwaggerFiles": "buildSwaggerFiles",
},
but when I run npm run buildSwaggerFiles
, I recieve the error that I either misspelled the command, or it doesn't exist (It's in german otherwise I'd just paste the error here). The same error pops up if I add .bat
:
"scripts": {
"buildSwaggerFiles": "buildSwaggerFiles.bat",
},
So I thought I needed to add the path, even though I haven't seen that online anywhere? It then looked like this:
"scripts": {
"buildSwaggerFiles": "projects/common/src/lib/buildSwaggerFiles.bat",
},
Same error, so I added npm run
:
"scripts": {
"buildSwaggerFiles": "npm run projects/common/src/lib/buildSwaggerFiles.bat",
},
And then I get the error npm ERR! Missing script: "projects/common/src/lib/buildSwaggerFiles.bat"
, however when I run npm run
, it shows me this:
Scripts available in [email protected] via npm run-script:
buildSwaggerFiles
projects/common/src/lib/buildSwaggerFiles.bat
At this point I am lost. Am I in the wrong Terminal? The terminal destination is Angular-Library, which contains the mentioned 'projects' folder, as well as the package.json. To clarify, the package.json is in the same folder as the projects folder that contains the script I am trying to run. Is that my problem? Can I not run .bat files through package.json? What else can I try? Thank you in advance.
CodePudding user response:
For anyone who may find this useful:
I managed to solve it by putting node
before listing the path to my script file, like so:"buildSwaggerFiles": "node projects/common/src/lib/buildSwaggerFiles.bat",