因此,我正在尝试制作一个小的脚本来运行我的tomcat服务器并执行npm run serve
以启动我的vue项目。
但是,如果我打开CMD并cd到项目中,就会出现问题,我可以执行npm run serve
,它确实可以工作,但是如果我尝试从批处理文件中调用它,则无法工作。 Vue应用程序位于名为“ test-app”的文件夹中,这是我的批处理文件:
set CATALINA_HOME="C:\workspaces\apache-tomcat-8.5.39"
set PATH="%CATALINA_HOME%\bin"
set PATH=%APPDATA%\npm;%PATH%
start cmd /k call "C:\workspaces\apache-tomcat-8.5.39\bin\startup.bat"
start cmd /k call "test-app/webserver.bat"
webserver.bat:
cd test-app
call npm run serve
tomcat服务器启动正常,但显然不行。这是输出:
C:\Users\Kenneth\Desktop\Start av servere>cd test-app
C:\Users\Kenneth\Desktop\Start av servere\test-app>call npm run serve
'npm' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\Kenneth\Desktop\Start av servere\test-app>
我也尝试过
cd test-app
start npm run serve
和
cd test-app
call npm run serve
以及
cd test-app
npm run serve
答案 0 :(得分:0)
我删除了set PATH=%APPDATA%\npm;%PATH%
,并将set PATH="C:\Program Files\nodejs"
添加到了主批处理文件。所以它看起来像这样:
echo "Vent litt så starter serverne - tar ca 2min for komplett oppstart. Ikke lukk vinduene som åpner."
set CATALINA_HOME="C:\workspaces\apache-tomcat-8.5.39"
set PATH="%CATALINA_HOME%\bin"
set PATH="C:\Program Files\nodejs"
start cmd /k call "C:\workspaces\apache-tomcat-8.5.39\bin\startup.bat"
start cmd /k call "test-app/webserver.bat"