简体   繁体   English

如何使用 NSIS 打包 nodejs 并安装 Windows 服务?

[英]How to package nodejs and install a windows service with NSIS?

I am currently using os-service to create a Windows service that needs to be packaged with my Electron application.我目前正在使用os-service创建一个需要与我的 Electron 应用程序一起打包的 Windows 服务。 Currently, everything is installed with NSIS, but I'm not quite sure how to install and run an os-service script during installation.目前,一切都与 NSIS 一起安装,但我不太确定如何在安装过程中安装和运行os-service脚本。 Likewise for uninstallation.卸载也是一样。

Anyone with experience with this?任何有这方面经验的人? The service is installed using node to run the script.该服务是使用 node 安装来运行脚本的。

When you install Node.js runtime on target computer it should contain everything necessary to run apps properly.当您在目标计算机上安装 Node.js 运行时,它应该包含正确运行应用程序所需的一切。

Node.js also installs npm so it should be possible to execute npm install os-service from your NSIS installer somehow like this: Node.js 还安装npm,因此应该可以像这样从 NSIS 安装程序执行npm install os-service

  1. Install Node.js runtime from your installer (it is .msi package so use ExecWait command to run it from some Temp folder)从安装程序安装 Node.js 运行时(它是 .msi 包,因此使用 ExecWait 命令从某个 Temp 文件夹运行它)
  2. Get the npm path .获取 npm路径 Here I suppose npm on Windows is something like npm.exe located in bin or similar directory of Node.js and the path can be retrieved from Registry.这里我假设 Windows 上的 npm 类似于位于 bin 或 Node.js 类似目录中的 npm.exe ,并且可以从注册表中检索路径。
  3. Run the npm: npm install os-service from your installer - again use ExecWait or related.运行 npm: npm install os-service从你的安装程序 - 再次使用 ExecWait 或相关的。 You will have to use absolute paths and so on.您将不得不使用绝对路径等。

I have no experience with web apps, there more be some dependencies and so on so you need to do a little more investigation.我没有使用网络应用程序的经验,还有一些依赖项等等,所以你需要做更多的调查。

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

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