Author -  Sai gowtham

How to resolve can't find module error in Node.js

In this tutorial, we are going to learn about how to resolve can’t find a module error in Node.js.

If you are not installed a module properly using npm install command and trying to use it in your project by using require() function you will see this following error inside the terminal.

internal/modules/cjs/loader.js:796
    throw err;
    ^

Error: Cannot find module '/Users/saigowtham/Desktop/sss/run'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:793:17)
    at Function.Module._load (internal/modules/cjs/loader.js:686:27)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
    at internal/main/run_main_module.js:17:11 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

To fix Cannot find module errors, install the modules properly by running a npm install command in the appropriate directory as your project’s app.js or index.js file.

Here is an example:


# npm install your-module-name

npm install express

or delete the node_modules folder and package-lock.json file and re-install it again using the npm install command.

rm -rf node_modules package-lock.json

Can’t find modules in local files

If you are trying to import one local file inside another and passed a wrong path to the require() function you will see this error again.

To fix this error, pass a correct module path to the require() function.

Css Tutorials & Demos

How rotate an image continuously in CSS

In this demo, we are going to learn about how to rotate an image continuously using the css animations.

How to create a Instagram login Page

In this demo, i will show you how to create a instagram login page using html and css.

How to create a pulse animation in CSS

In this demo, i will show you how to create a pulse animation using css.

Creating a snowfall animation using css and JavaScript

In this demo, i will show you how to create a snow fall animation using css and JavaScript.

Top Udemy Courses

JavaScript - The Complete Guide 2023 (Beginner + Advanced)
JavaScript - The Complete Guide 2023 (Beginner + Advanced)
116,648 students enrolled
52 hours of video content
$14.99 FROM UDEMY
React - The Complete Guide (incl Hooks, React Router, Redux)
React - The Complete Guide (incl Hooks, React Router, Redux)
631,582 students enrolled
49 hours of video content
$24.99 FROM UDEMY
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
203,937 students enrolled
31.5 hours of video content
$14.99 FROM UDEMY