I wrote a simple Express application. It ran correctly with "npm start". The scripts in package.json is this:
"type": "module",
"scripts": {
"start": "src/bin/www.js"
}
But I couldn't execute it like this:
pm2 start ./src/bin/www.js
I checked pm2.log. It shown "had too many unstable restarts(16)".
Then ran it with pm2-dev:
pm2-dev start ./src/bin/www.js
Reported the error:
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module:
Pm2 can't work well with import/export? The node version is 14.16.0.
First make sure if you have following two points:
If both are true and it's still not working then you might be victim of following github issue
https://github.com/Unitech/pm2/issues/4540
For now you can try running it with babel!