I am running a JavaScript code on Ubuntu server using node.js I got this error.
module.js:340
throw err;
^
Error: Cannot find module './lib/compat'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/usr/lib/nodejs/node_modules/express/node_modules/depd/index.js:11:24)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
How to debug this error?
Edit: using these dependencies.
var express = require('express');
var fs = require('fs');
var request = require('request');
var cheerio = require('cheerio');
I am running a JavaScript code on Ubuntu server using node.js I got this error.
module.js:340
throw err;
^
Error: Cannot find module './lib/compat'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/usr/lib/nodejs/node_modules/express/node_modules/depd/index.js:11:24)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
How to debug this error?
Edit: using these dependencies.
var express = require('express');
var fs = require('fs');
var request = require('request');
var cheerio = require('cheerio');
Share
Improve this question
edited Jun 6, 2015 at 18:40
edinvnode
asked Jun 6, 2015 at 18:26
edinvnodeedinvnode
3,5477 gold badges34 silver badges56 bronze badges
4
- What other dependencies do you have? Something you are using may be old enough it is not directly compatible with Node. – Jon Edwards Commented Jun 6, 2015 at 18:30
- That error is about module.require. Seems like you are requiring/including a file that does not exist (file path wrong maybe). Look at your code for './lib/compat'. – ecarrizo Commented Jun 6, 2015 at 18:31
- I edited the code and checked for your proposition. It's not about includinga file that doesn't exist... – edinvnode Commented Jun 6, 2015 at 18:41
- Show us your node application file! – Robert Moskal Commented Jun 6, 2015 at 19:16
2 Answers
Reset to default 11The problem can persist even after running:
npm uninstall express
npm install express --save
If this happens delete the node-modules folder and then run:
npm install express
and
npm install
to reinstall all the packages listed in packages.json
The problem is not directly in your code, but in the dependency of one of the modules you're using. You see it at this line of the error message:
at Object.<anonymous> (/usr/lib/nodejs/node_modules/express/node_modules/depd/index.js:11:24)
express
module has a dependency called depd
, which is the module in trouble.
How did you install your modules?
There has probably been some problem when you have installed express.
The folder lib/compat
is directly part of depd, so there's no reason it should be missing.
You may want to do the following:
npm uninstall express
npm install express --save
This would reinstall express, hopefully solving the issue.