如何在Forever中使用选项-r esm运行脚本?

使用以下配置,将引发错误
Unexpected token import

配置:

{
  "uid": "app",
  "script": "index.js",
  "sourceDir": "./",
  "args": ["-r", "esm"]
}


命令:forever start ./config.json

我已经安装了esm,如果我运行node -r esm ./index.js,它会完美运行。

最佳答案

试试看,经过数小时的搜索,它对我有用。

sudo forever start -c "node -r esm" index.js

09-26 02:05