keymetrics / pm2-plus-tech-questions

http://docs.keymetrics.io/docs/pages/faq-troubleshooting/
27 stars 3 forks source link

error when run pm2 start for ecosystem.config.js #287

Closed YallaDealz closed 3 years ago

YallaDealz commented 3 years ago

i run nuxtjs app on my server and running normally but today ii tried to push changes and tried to start nuxttjs service via pm2 i got this error " this first time "

[PM2][ERROR] File ecosystem.config.js malformated Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /home/yalladealz/Dashboard/ecosystem.config.js require() of ES modules is not supported. require() of /home/yalladealz/Dashboard/ecosystem.config.js from /root/.nvm/versions/node/v16.5.0/lib/node_modules/pm2/lib/Common.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules. Instead rename ecosystem.config.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /home/yalladealz/Dashboard/package.json.

at new NodeError (node:internal/errors:370:5)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1112:13)
at Module.load (node:internal/modules/cjs/loader:975:32)
at Function.Module._load (node:internal/modules/cjs/loader:816:12)
at Module.require (node:internal/modules/cjs/loader:999:19)
at require (node:internal/modules/cjs/helpers:93:18)
at Object.Common.parseConfig (/root/.nvm/versions/node/v16.5.0/lib/node_modules/pm2/lib/Common.js:317:12)
at API._startJson (/root/.nvm/versions/node/v16.5.0/lib/node_modules/pm2/lib/API.js:939:25)
at API.start (/root/.nvm/versions/node/v16.5.0/lib/node_modules/pm2/lib/API.js:334:12)
at /root/.nvm/versions/node/v16.5.0/lib/node_modules/pm2/lib/binaries/CLI.js:290:13 {

code: 'ERR_REQUIRE_ESM' }

my ecosystem.config.js file 👍

module.exports = { apps : [ { name: "Dashboard", script: "npm", args: "run start" } ] }