I created the following file
我创建了以下文件
//npminstall.bat
//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 .
当我从Windows 10命令行(dos)npminstall.bat运行以下命令时,npm install命令将触发,但不会触发echo hello。我尝试在第一行之后放一个半色,就像这个npm install;,但所有这一切都给了我npm的帮助说明。
How do I get the second line echo hello
to fire after the npm install
?
在npm安装后如何让第二行echo hello触发?
Additional Notes
补充笔记
I have found that this also causes the same behaviour:
我发现这也导致了同样的行为:
//npminstall.bat
//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.
我认为这是因为npm install命令和webpack命令都需要时间来执行,并且在那段时间内它会成为我不希望第二行的东西。
Followup 2
后续2
//npminstall.bat
//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?
这似乎几乎可以做我想做的事情。除了npm install命令导致弹出窗口,我必须在继续执行之前关闭弹出窗口以回显hello world。我可以摆脱弹出窗口吗?
1 个解决方案
#1
44
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命令将控制权返回给父进程,否则控制权将传递给正在执行的批处理文件。
call npm install
#1
44
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命令将控制权返回给父进程,否则控制权将传递给正在执行的批处理文件。
call npm install