【发布时间】:2022-01-23 18:05:01
【问题描述】:
如何将 pm2 与基于 ES 模块的包结合使用(类型:“模块”) 我在没有任何有用帮助的情况下查看了类似的问题(有人说它在 Windows 上不起作用,但我使用的是 linux)
我总是收到错误:
Error [ERR_REQUIRE_ESM]: require() of ES Module /opt/app/server/lib/src/index.js not supported.
0|any| Instead change the require of index.js in null to a dynamic import() which is available in all CommonJS modules.
我的生态系统.config.js 看起来像:
const os = require('os');
module.exports = {
apps: [{
port : 3000,
name : "any",
script : "lib/src/index.js",
watch : true,
instances : os.cpus().length,
exec_mode : 'fork',
env: {
NODE_ENV: "production",
}
}]
}
index.js 是一个使用“import”语法的 ES 模块。我如何告诉 pm2 应该使用这种导入方式
【问题讨论】:
标签: javascript pm2