Reputation: 2069
I have an angular application, that can be started with the command npm start
in the console. Now I want to create a batchfile, that executes "npm install" when started. This is the batch file I created:
frontend.bat
cd "<path>"
npm start
When I execute the File, the console shows up quickly, but then nothing happens.
My question is, is it even possible to do npm start in a batch file? And if not, is there another way to start a angular application with a batch file?
Thank you
Upvotes: 5
Views: 16115
Reputation: 2356
Another way is writing cmd /k
at the end of the file. It is better than pause
, because with pause
terminal window will be closed anyway once any key is pressed. cmd /k
will leave the window open and ready for input. To maintain clean terminal you can add @echo off
before it, so the cmd /k
does not get printed.
cd "<path>"
npm start
@echo off
cmd /k
Upvotes: 2
Reputation: 4750
NPM does an EXIT. You can do this (modify as desired).
CMD /C "%ProgramFiles%\nodejs\npm" i --loglevel error
Upvotes: 2
Reputation: 1280
you could try to pause the execution of the batch file with
cd "<path>"
npm start
pause
otherwise the batch file will exit and take npm down with it.
Upvotes: 6