我如何将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.
我的 Ecosystem.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 应该使用这种导入方式
重命名ecosystem.config.js
to ecosystem.config.cjs
为我工作
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)