Error: cannot find module ‘node:events’ occur in Node.js when you try to “use a built-in module using the node: prefix, which was introduced in Node.js version 14.x for ES modules.”
There are two main reasons for the error.
- When running an older version of Node.js that doesn’t support the “node:” prefix.
- When you have misconfigured the ES modules in your project.
How to fix the error?
Here are three solutions to fix the error.
- Upgrade your Node.js version to the latest version.
- Use Without “node:” Prefix if you are using an older version.
- Ensure Proper ES Module Configuration.
Solution 1: Upgrade your Node.js version to the latest version
The easiest way to fix the cannot find module ‘node:events’ error is by upgrading your system’s Node.js to the latest version.
Solution 2: Use Without “node:” Prefix if you are using an older version.
If you are on an older version of Node.js and can’t update for some reason, or if you just want to avoid the prefix, you can simply require the “events” module without the “node:” prefix:
import { EventEmitter } from 'events';
or using CommonJS:
const { EventEmitter } = require('events');
Solution 3: Ensure Proper ES Module Configuration
If you are using ES modules (with import/export syntax), ensure that you have set the “type” field in your package.json to “module”.
{
"type": "module"
}
This configuration lets Node.js know you are using ES modules in your project.
I hope these solutions will fix your error.
Related posts
nodemon clean exit – waiting for changes before restart
Error: listen EADDRINUSE: address already in use in Node.js
ReferenceError: primordials is not defined error in Node.js

Krunal Lathiya is a seasoned Computer Science expert with over eight years in the tech industry. He boasts deep knowledge in Data Science and Machine Learning. Versed in Python, JavaScript, PHP, R, and Golang. Skilled in frameworks like Angular and React and platforms such as Node.js. His expertise spans both front-end and back-end development. His proficiency in the Python language stands as a testament to his versatility and commitment to the craft.