简体   繁体   English

bat文件不会暂停执行

[英]bat file doesn't pause execution

I'm using a bat file to run my nodejs app in windows 7 . 我正在使用bat文件在Windows 7中运行我的nodejs应用程序。 The bat file contains following lines, bat文件包含以下几行,

cd "C:/dev/nodeapp/"
npm start
pause

But the bat file doesn't pause. 但是bat文件不会暂停。 Because of that I can't see the errors on cmd when nodejs throws errors. 因此,当nodejs引发错误时,我看不到cmd上的错误。 I tried cmd /k instead of pause , it doesn't work either. 我尝试了cmd /k而不是pause ,它也不起作用。

Anybody knows a way to pause the bat file execution here? 有人知道在这里暂停bat文件执行的方法吗?

I notice that the problem is with the line npm start . 我注意到问题出在npm start行。 When I remove that line the pause works..! 当我删除该行时, pause起作用。

Thank you in advance... 先感谢您...

It does not pause because in windows npm is a batch file ( npm.cmd ). 它不会暂停,因为在Windows中npm是一个批处理文件( npm.cmd )。 Directly invocation of a batch file from inside a batch file transfers the execution to the called one, and does not return to the caller. 从批处理文件内部直接调用批处理文件会将执行转移到被调用者,而不会返回到调用方。 You need to use call command 您需要使用call命令

cd "C:/dev/nodeapp/"
call npm start
pause

我认为这里暂停是不正确的尝试:npn stop

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM