I have a simple .bat file so i can easily execute npm commands without typing them everytime, but when i try it with 'npm run build' the window closes after the script finishes.
I cant see the results from npm run build :/.
I tried PAUSE or cmd /k but the cmd keeps closing...
create-build.bat:
cd myfolder
npm run build
Thanks in advance!
Add a pause statement to a batch file If you're creating a batch file and want the MS-DOS window to remain open, add PAUSE to the end of your batch file. This prompts the user to Press any key. Until the user presses any key, the window remains open instead of closing automatically.
Type the "cmd /k" parameter before every command to keep the window from closing. To open a folder with the command prompt, hold down the "Shift" key, right-click on the folder and select "Open command window here."
To prevent the Command Prompt from closing automatically:Press Windows key + R to open the Run window. Adding / K after the command keeps the window open. You can, then, close the window manually when you no longer need it to be open.
You can insert the pause command before a section of the batch file that you might not want to process. When pause suspends processing of the batch program, you can press CTRL+C and then press Y to stop the batch program.
prefix 'call' to your npm commnands: eg
call npm i -D eslint eslint-config-airbnb-base eslint-pl
This is a work around, and it's good to understand the limitations. A decent discussion can be found here: https://github.com/npm/npm/issues/2938
npm evidently does an EXIT. here is the command line I use to do that.
CMD /C "C:\Program Files\nodejs\npm" i --loglevel error
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With