Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

creating a .bat file with npm install command

I created the following file

//npminstall.bat

npm install echo hello 

When I run the following command from Windows 10 Command Line (dos) npminstall.bat, the npm install command fires, but the echo hello doesn't fire. I tried putting a semi-color after the first line like this npm install;, but all that did was give me the help instructions of npm .

How do I get the second line echo hello to fire after the npm install?

Additional Notes

I have found that this also causes the same behaviour:

//npminstall.bat

webpack echo hello 

I think it's because both the npm install command and webpack command takes time to execute, and during that time it doe ssomething I don't expect to the second line.

Followup 2

//npminstall.bat

START /WAIT npm install echo hello 

This seems to almost do what I want to do. Except the npm install command causes a pop up window, and i have to shut down teh pop up window before it continues execution to echo hello world. Can I get rid of the popup window?

like image 765
John Avatar asked Feb 17 '17 18:02

John


People also ask

How do I create a .bat file?

To create a Windows batch file, follow these steps: Open a text file, such as a Notepad or WordPad document. Add your commands, starting with @echo [off], followed by, each in a new line, title [title of your batch script], echo [first line], and pause. Save your file with the file extension BAT, for example, test.


1 Answers

When you access another batch file from a batch file, you need to use the CALL command to return control to parent process otherwise control is passed to the batch file being executed.

call npm install 
like image 75
Squashman Avatar answered Oct 23 '22 03:10

Squashman