Ive enabled ES modules in pacakage.json
with this key value pair "type": "module"
i dont have to use the 'experimental' flag with the latest version of node
when i run pm2 start app.js --watch
the app crashes with the error message
0|app | Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only file and data URLs are supported by the default ESM loader
0|app | at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:781:11)
0|app | at Loader.resolve (internal/modules/esm/loader.js:85:40)
0|app | at Loader.getModuleJob (internal/modules/esm/loader.js:229:28)
0|app | at Loader.import (internal/modules/esm/loader.js:164:28)
0|app | at importModuleDynamically (internal/modules/cjs/loader.js:1194:27)
0|app | at exports.importModuleDynamicallyCallback (internal/process/esm_loader.js:30:14)
0|app | at Object.<anonymous> (C:\Users\username\AppData\Roaming\npm\node_modules\pm2\lib\ProcessContainerFork.js:29:24)
0|app | at Module._compile (internal/modules/cjs/loader.js:1251:30)
0|app | at Object.Module._extensions..js (internal/modules/cjs/loader.js:1272:10)
0|app | at Module.load (internal/modules/cjs/loader.js:1100:32) {
0|app | code: 'ERR_UNSUPPORTED_ESM_URL_SCHEME'
0|app | }
the app works perfectly fine without pm2. im guessing pm2 does not support ESM yet!
any workarounds or am i missing some configurations?
from PM2 crashes while using ES modules in nodejs
No comments:
Post a Comment