簡體   English   中英

在 Windows 上運行forever.js 時出錯-“'C:\\Program' 不是內部或外部命令、可運行的程序或批處理文件”

[英]Error running forever.js on Windows - "'C:\Program' is not recognized as an internal or external command, operable program or batch file"

我試圖通過 Windows 命令提示符運行forever.js ,我得到以下輸出:

>npm i -g forever

/my-project>forever start index.js

日志輸出:

'C:\\Program' is not recognized as an internal or external command, operable program or batch file

我認為這與forever用於node二進制文件的PATH有關,但我不知道如何修復它...

編輯:永遠使用以下命令(用引號" "括起來):

"C:\\Program Files\\nodejs\\node.exe"

如果在 c: 的根目錄中鍵入dir /x ,則可以看到目錄的短名稱

因此,請嘗試以下操作:

C:\PROGRA~1\nodejs\node.exe

目錄/x 示例

安裝永久版本 1.0.0 為我解決了這個問題

我對永遠 2.0.0 有同樣的問題。

我在“forever.js”中使用了一種解決方法:(我通過“node ever.js”啟動我的應用程序)

const configChild = {
    //
    // Basic configuration options
    //
    silent: true,    // Silences the output from stdout and stderr in the parent process
    'killTree': true, // Kills the entire child process tree on `exit`
    ....
}

// =======================================================
// **Workaround for Windows** 
// =======================================================
if (process.platform === 'win32' && process.execPath == "C:\\Program Files\\nodejs\\node.exe") {
    configChild.command = '"C:\\PROGRA~1\\nodejs\\node.exe"';
}

const child = new (forever.Monitor)('app.js', configChild);

....

child.start();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM