serverless: [v3] Node v22.12.0 Error _serverlessExternalPluginName
Issue description
Just getting this error while running v2 on the node release v22.12.0
TypeError: Cannot redefine property: _serverlessExternalPluginName
at Function.defineProperty (<anonymous>)
at PluginManager.resolveServicePlugins (/api/node_modules/serverless/lib/classes/plugin-manager.js:230:14)
at async PluginManager.loadAllPlugins (/api/node_modules/serverless/lib/classes/plugin-manager.js:136:36)
at async Serverless.init (/api/node_modules/serverless/lib/serverless.js:146:5)
at async /api/node_modules/serverless/scripts/serverless.js:601:7
Context
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 13
- Comments: 15 (3 by maintainers)
Commits related to this issue
- Update package.json to fix node v22.12 error on serverless The error is the same as stated here serverless/serverless#12936 as the version target as dependency for the serverless-offline v13 is serve... — committed to eusousu/serverless-offline by eusousu 2 years ago
- fix: sets fixed serverless version 3.40.0 Ref: https://github.com/serverless/serverless/issues/12936 — committed to mapadoacolhimento/lambda-pedido-acolhimento by vivianedias a year ago
- fix: sets fixed serverless version 3.40.0 Ref: https://github.com/serverless/serverless/issues/12936 — committed to mapadoacolhimento/lambda-pedido-acolhimento by vivianedias a year ago
- fix: upgrade serverless to fix https://github.com/serverless/serverless/issues/12936 — committed to HathorNetwork/hathor-wallet-service by luislhl a year ago
Hey everyone, we’ve just released v3.40.0, which resolves the Node v22.12 incompatibility. Feel free to update and give it a try.
Hey, this issue is caused by Node v22.12 due to a change in how it loads native ES modules
As a workaround, you can disable this experimental feature by setting the following environment variable before running Serverless:
We’re seeing
ERR_REQUIRE_ASYNC_MODULEthrown at line 5 inrequire-with-import-fallback.jsRESOLVED: We resolved by disabling both experiments:
This also happens with 3.40.0. Adding
NODE_OPTIONS=--no-experimental-require-modulebeforesls packagedoesn’t fix it but it changes the error.I wonder if the problem we are seeing is triggered by the experimental detect module flag that was enabled by default as of Node 22.7.0.
https://nodejs.org/api/cli.html#--no-experimental-detect-module
This seems to pose a problem for TypeScript:
https://github.com/microsoft/TypeScript/issues/56678
Our scenario may be the one described here:
https://github.com/nodejs/node/blob/main/doc/changelogs/CHANGELOG_V22.md#requireesm-is-now-enabled-by-default
Any insight would be appreciated.
This applies to node 20.19.x and Serverless 3.39 and 3.40. For us, rolling back to node 20.18.1 solved the problem.
The links to other tickets may make that clear, but just to be pretty explicit, as this is the only ticket that comes up on Google searches for me about this and the title may make you think otherwise.
node LTS version 20.18.1 works.
Hi @eudoroolivares2016, Nope. This appears to be an issue related to a (breaking?) change in Node.js V22, distributed in one of its minor releases. A few other projects seem affected. We’ll continue to look into this.
I can see that this works on node version 22.11.0 and breaks on versions 22.12.0.