[Fix] Cannot find module ‘express’ error in Node.js 

When I am trying to import the express package into Node.js, it is showing me Cannot find module ‘express’ error.

Below I am mentioning the reason and how we can fix Cannot find module ‘express’ error in Node.js.

Why Cannot find module ‘express’ error in Node.js is seen?

Cannot find module ‘express’ error in Node.js is basically seen because of missing of express package, to fix the error, install the express package using the command npm install express in the root directory of your project. if you are not having the package.json file, first create the file using the command npm init -y.

How to Fix Cannot find module ‘express’ error in Node.js?

To fix Cannot find module ‘express’ error in Node.js, install the express package using the command npm install express in the root directory of your project. if you are not having the package.json file, first create the file using the command npm init -y. Once you install the express package, your error would resolve immediately and you can run project without any issue.

Below are the steps to fix Fix Cannot find module ‘express’ error in Node.js:

Step 1: Initialise package.json File

First check if you are having the package.json file into your project or not, if not, initialise your project’s root directory using the below command:

npm init -y

Step 2: Install express package

Once you are sure that you have package.json File, now install the express package using below command:

npm install express

Conclusion

To fix Cannot find module ‘express’ error in Node.js, install the express package using the command npm install express in the root directory of your project. if you are not having the package.json file, first create the file using the command npm init -y.

Once you install the express package, your error would resolve immediately and you can run project without any issue.