我已经使用 Inno Setup 为我制作的应用程序创建了一个 Windows 安装程序。作为安装程序的一部分,我安装了一些第三方应用程序,然后是一个批处理文件,以执行许多 npm
命令可操作程序或批处理文件。
一切安装正常,但是当批处理文件运行时,我收到消息
'npm' is not recognized as an internal or external command
命令不会运行,因此应用程序不会打开。但是,如果我将所有内容保留原样,然后在安装后再次重新运行批处理文件,则命令将执行并且应用程序可以正常工作。如何使批处理文件作为安装的一部分正确运行?
Inno 设置 Run
部分
[Run]
Filename: "{tmp}\Git-2.15.0-64-bit.exe"; Flags: waituntilterminated
Filename: "{tmp}\rubyinstaller-2.3.3-x64.exe"; Flags: waituntilterminated
Filename: "{tmp}\visualcppbuildtools_full.exe"; Flags: waituntilterminated
Filename: "msiexec.exe"; Parameters: "/i ""{tmp}\mongodb-win32-x86_64-2008plus-ssl-3.4.10-signed.msi"; WorkingDir: {tmp}; Flags: waituntilterminated
Filename: "msiexec.exe"; Parameters: "/i ""{tmp}\node-v6.11.0-x64.msi"; WorkingDir: {tmp}; Flags: waituntilterminated
Filename: "{tmp}\setup.bat";
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: shellexec postinstall skipifsilent
批处理文件
cd C:/Users/%USERNAME%/Documents/myApp/api/
call npm install -g bower
call npm install -g grunt
call npm install -g grunt-cli
call npm config set msvs_version 2015 -global
call npm install bcrypt -save
call npm install
cd ../admin/
call npm install -g bower
call npm install -g grunt
call npm install -g grunt-cli
echo 1 | call gem install compass
call bower install
call npm install
最佳答案
我猜安装程序不会为您修改 PATH,因此 npm 不会被别名为命令。如果您使用可执行文件的绝对路径调用 npm,它应该按预期工作。
关于node.js - Inno Setup - 在从安装程序执行的批处理文件中无法识别由子安装程序添加到 PATH 的 npm 程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47681827/