close

[Solved] Error: Cannot find module ‘express’

I am trying to use express in my node project but I am facing the following: Error: Cannot find module ‘express’ in Nodejs. In this Exerror article, We are going to Learn about How to reproduce this error and we will discuss All Possible Solutions Lets Get Start with This Article.

How Error: Cannot find module ‘express’ Occurs?

I am trying to use express in my node project but I am facing the following error.

Error: Cannot find module 'express'

So here I am writing all the possible solutions that I have tried to resolve this error.

How To Solve Error: Cannot find module ‘express’?

  1. How To Solve Error: Cannot find module 'express'?

    To Solve Error: Cannot find module 'express' You can also Run npm install command with –save then it will also install express module. Just open your terminal from the root of your project and simply run this command in your terminal: npm install express –save Now, Your error should be resolved.

  2. Error: Cannot find module 'express'

    To Solve Error: Cannot find module 'express' This error occurs whenever our app is looking for an express package and is unable to find this module in Our project. An easy and simple solution is Just to install Express in your project and Your error will be resolved. Open your terminal at the root of your project. And run this command in your terminal: npm install express And now, You can Use this Express module. Once you have installed express then your error will be solved.

Solution 1: Install express

This error occurs whenever our app is looking for an express package and is unable to find this module in Our project. An easy and simple solution is Just to install Express in your project and Your error will be resolved. Open your terminal at the root of your project. And run this command in your terminal.

npm install express

And now, You can Use this Express module just like below.

import express from 'express';

const app = express();
const port = 3445;

app.get('/', (req, res) => {
  res.send('Hello World!');
});

app.listen(port, () => {
  console.log(`Example app listening on port ${port}`);
});

Once you have installed express then your error will be solved.

Solution 2: run this command with save

You can also Run npm install command with –save then it will also install express module. Just open your terminal from the root of your project and simply run this command in your terminal.

npm install express --save

Now, Your error should be resolved.

Solution 3: Install express Globally

You can Also Install the Express module Globally So You Don’t have to install it Again and Again. Just run below command in your terminal with -g just like below.

npm install -g express --save

Solution 4: For linux users

If You are using Ubuntu Based OS then You can Run this Installation command and You can Also Use Sudo if you are facing any permission error.

sudo apt-get install node-express

Or You Can Also Run,

sudo npm install

Once you have installed express then your error will be solved.

Conclusion

It’s all About this error. Hope We solved Your error. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?

Also, Read

Leave a Comment