pm2 for production
hello, how to use pm2 for making a refine.dev app going live ?
I got this error using a file called ecosystems.config.js with the following content:
module.exports = {
apps: [
{
name: 'spiderlink',
script: 'yarn',
args: 'start',
env: {
NODE_ENV: 'production',
},
exp_backoff_restart_delay: 100,
},
],
};
then using pm2 start ecosystems.config.js i got this error:
[PM2][ERROR] File ecosystems.config.js malformated
Error [ERR_REQUIRE_ESM]: require() of ES Module /data_efs/node/spiderlink/spiderlink/ecosystems.config.js from /root/.nvm/versions/node/v18.18.2/lib/node_modules/pm2/lib/Common.js not supported.
ecosystems.config.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead rename ecosystems.config.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /data_efs/node/spiderlink/spiderlink/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).
I got this error using a file called ecosystems.config.js with the following content:
module.exports = {
apps: [
{
name: 'spiderlink',
script: 'yarn',
args: 'start',
env: {
NODE_ENV: 'production',
},
exp_backoff_restart_delay: 100,
},
],
};
then using pm2 start ecosystems.config.js i got this error:
[PM2][ERROR] File ecosystems.config.js malformated
Error [ERR_REQUIRE_ESM]: require() of ES Module /data_efs/node/spiderlink/spiderlink/ecosystems.config.js from /root/.nvm/versions/node/v18.18.2/lib/node_modules/pm2/lib/Common.js not supported.
ecosystems.config.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead rename ecosystems.config.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /data_efs/node/spiderlink/spiderlink/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).
