nodejs程序配置成windows-server服務,實現開機自啟動


1、安裝node-windows依賴

npm install node-windows --save

2、在項目根目錄創建nw.js文件

let Service = require('node-windows').Service;
 
let svc = new Service({
  name: 'node_service',    //服務名稱
  description: 'node服務器', //描述
  script: './bin/www' //nodejs項目要啟動的文件路徑
});
 
svc.on('install', () => {
  svc.start();
});
 
svc.install();

3、運行

node nw.js

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM