node.js - Inno Setup - 在从安装程序执行的批处理文件中无法识别由子安装程序添加到 PATH 的 npm 程序

标签 node.js batch-file npm inno-setup

我已经使用 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/

相关文章:

javascript - node.js 和 express 中的异常处理

windows - 如何在 Windows 中通过命令行创建快捷方式?

npm - travis-ci 打字安装失败

node.js - 为什么 grunt 不能通过 Bower.js 安装?

npm - 如何使用 Azure Devops 管道增加 npm 包的版本

Javascript - 将 this 参数绑定(bind)到 Promise

node.js - 我们可以同时使用 NGINX 和 PM2 进行 node.js 生产部署吗?

python - 如何使用 NodeJS 在单个 HTTP POST 中发送文件和 JSON 数据(元数据)

cmd - 批处理脚本参数中的空格

windows - 通过批处理或类似方式在Windows嵌入式标准上设置互联网时间服务器