Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node : Cannot find module common

I was running a node server w/o any issue and for some purpose had to remove the node_modules dir and re-install the dependencies. Upon doing so and running the server again I get this error :

Error: Cannot find module './common'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (C:\Work\Cinde-Node\node_modules\debug\src\node.js:236:18)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)

I installed common separately using npm install common but that didnt solve the problem.

How do I fix this ?

like image 357
vivekanon Avatar asked Aug 06 '26 00:08

vivekanon


2 Answers

It looks like you have a line like require('./common'); it should be require('common')

like image 116
wanjas Avatar answered Aug 08 '26 19:08

wanjas


I was also facing same problem like:

Error: Cannot find module './sdam/common'

So I just removed the node_modules folder, then just ran command npm i.

That will download every dependencies mentioned in package.json file.

like image 33
tosifhk2000 Avatar answered Aug 08 '26 17:08

tosifhk2000



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!