使用npm install命令创建.bat文件 [英] creating a .bat file with npm install command

查看:162
本文介绍了使用npm install命令创建.bat文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了以下文件

//npminstall.bat

//npminstall.bat

npm install
echo hello

当我从Windows 10命令行(dos) npminstall.bat 运行以下命令时,会触发 npm install 命令,但 echo hello 不会触发.我尝试在第一行之后加上半彩色,例如 npm install; ,但是所做的只是为我提供了npm的帮助说明.

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 .

如何在 npm install 之后触发第二行 echo hello ?

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

附加说明

我发现这也会引起相同的行为:

I have found that this also causes the same behaviour:

//npminstall.bat

//npminstall.bat

webpack
echo hello

我认为这是因为 npm install 命令和 webpack 命令都需要时间来执行,在此期间,它确实有些意外,我不希望第二行

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.

后续2

//npminstall.bat

//npminstall.bat

START /WAIT npm install
echo hello

这似乎几乎可以完成我想做的事情.除了npm install命令会导致一个弹出窗口,而且我必须先关闭弹出窗口,然后它才能继续执行以回应hello world.我可以摆脱弹出窗口吗?

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?

推荐答案

当您从批处理文件访问另一个批处理文件时,需要使用CALL命令将控制权返回给父进程,否则控制权将传递给正在处理的批处理文件.被执行.

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

这篇关于使用npm install命令创建.bat文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆