pm2 index.js返回ERR_REQUIRE_ESM

问题描述

我运行status显示online

pm2 start index.js
但是一旦调用API,它就会返回ERR_REQUIRE_ESM

我尝试解决

  1. 将index.js文件重命名为index.mjs并运行pm2 start index.mjs
  2. 安装esm软件包并运行pm2 start ecosystem.config.js

ecosystem.config.js

module.exports = {
  apps : [{
    name: 'backend',script: 'index.js',instances: 1,autorestart: true,watch: true,max_memory_restart: '1G',env: {
      NODE_ENV: 'development'
    },env_production: {
      NODE_ENV: 'production'
    }
  }]
};

这两种方法均失败。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)