Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Cannot find module 'node:events' #12418

Open
Bobby484 opened this issue Apr 9, 2024 · 3 comments
Open

Error: Cannot find module 'node:events' #12418

Bobby484 opened this issue Apr 9, 2024 · 3 comments

Comments

@Bobby484
Copy link

Bobby484 commented Apr 9, 2024

Issue description

I am seeing this issue in the aws codebuild container. I have serverless@3.18.0 and nodejs 12.20.0. It is very difficult for us to upgrade to nodejs 16. Is there any workaround for it? Tried downgrading simple-git 3.22.0 but no luck. Please help as it is very critical for us. I strongly believe it is something to do with simple-git package dependency. They have released version 12 days ago which is causing serverless to fail.

Error: Cannot find module 'node:events'

Require stack:

  • /usr/local/lib/node_modules/serverless/node_modules/simple-git/dist/cjs/index.js

  • /usr/local/lib/node_modules/serverless/node_modules/@serverless/dashboard-plugin/lib/deployment/parse.js

  • /usr/local/lib/node_modules/serverless/node_modules/@serverless/dashboard-plugin/lib/deployment/index.js

  • /usr/local/lib/node_modules/serverless/node_modules/@serverless/dashboard-plugin/lib/error-handler.js

  • /usr/local/lib/node_modules/serverless/node_modules/@serverless/dashboard-plugin/lib/plugin.js

  • /usr/local/lib/node_modules/serverless/node_modules/@serverless/dashboard-plugin/index.js

  • /usr/local/lib/node_modules/serverless/lib/cli/handle-error.js

  • /usr/local/lib/node_modules/serverless/scripts/serverless.js

Context

I am still seeing this issue in aws codebuild container. I have serverless@3.18.0 and nodejs 12.20.0. It is very difficult for us to upgrade to nodejs 16. Is there any workaround on it? Tried downgrading simple-git 3.22.0 but no luck. Please help as it is very critical for us.

@aayushgupta97
Copy link

I have the exact same issue, using serverless 3.22 and node@12.

Upgrading node to 14 also requires an update of python version and it's not possible right now for us.

@aayushgupta97
Copy link

aayushgupta97 commented Apr 11, 2024

Hey @Bobby484
This is the exact root cause: serverless-framework uses @serverless/dashboard-plugin which internally uses simple-git.
However, in the package.json for dashboard-plugin, it installs simple-git with a carat. @^3.16, which means the latest version after 3.16, which is version 3.24

However, the format for importing like this node:events, is only supported from node14, hence the error.

I found a workaround for it. In my buildspec.yml after installing the serverless@3.22, I installed simple-git in it's node_modules directory.

 - current_dir=$(pwd)

 - npm install -g serverless@3.22.0
 
 - cd /usr/local/lib/node_modules/serverless
 
 - npm install simple-git@3.22.0
 
 - cd "$current_dir"

@Bobby484
Copy link
Author

Thank you so much. worked like a charm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants