在Windows上运行forever.js时出错-““ C:\ Program”未被识别为内部或外部命令,可操作程序或批处理文件”

我正在尝试通过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

我认为PATH用于forever二进制文件的node与它有关,但是我不知道如何解决它...

编辑:永远使用以下命令(由引号" "包围):

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

cengyicang 回答:在Windows上运行forever.js时出错-““ C:\ Program”未被识别为内部或外部命令,可操作程序或批处理文件”

如果在c:的根目录中键入dir /x,则可以看到目录的short name

因此,请尝试以下操作:

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

dir /x example

,

永久安装1.0.0版可以为我解决问题

,

我对forever 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();
本文链接:https://www.f2er.com/2780288.html

大家都在问