[英]pm2 cannot start express application
I wrote a simple Express application.我写了一个简单的 Express 应用程序。 It ran correctly with "npm start".
它使用“npm start”正确运行。 The scripts in package.json is this:
package.json 中的脚本是这样的:
"type": "module",
"scripts": {
"start": "src/bin/www.js"
}
But I couldn't execute it like this:但我不能像这样执行它:
pm2 start ./src/bin/www.js
I checked pm2.log.我检查了 pm2.log。 It shown "had too many unstable restarts(16)".
它显示“有太多不稳定的重启(16)”。
Then ran it with pm2-dev:然后用 pm2-dev 运行它:
pm2-dev start ./src/bin/www.js
Reported the error:报错:
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module:
Pm2 can't work well with import/export? Pm2 不能很好地用于导入/导出? The node version is 14.16.0.
节点版本为 14.16.0。
First make sure if you have following two points:首先确定你是否有以下两点:
If both are true and it's still not working then you might be victim of following github issue如果两者都是正确的并且仍然无法正常工作,那么您可能会成为关注 github 问题的受害者
https://github.com/Unitech/pm2/issues/4540 https://github.com/Unitech/pm2/issues/4540
For now you can try running it with babel!现在你可以尝试用 babel 运行它!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.