It appears that this simple app can\'t find the \'connect\'
module after I just installed it in the file directory.
var connect = require (\'connec
Express internally uses Connect as one of its node_modules dependencies.
If you wish to use Connect in your app, you'll need to add it to your package.json
and run npm update
.
By design, each node module has its own private internal dependencies.
If you want to use any, your app will need to install them too.
It means your app can use a different version of the modules, and each module can internally use different versions again without conflicts.
I had the same problem for express-http-proxy and the solution was to install the package with npm. At first I installed globally (-g) and it works. On another installation I had to use "--save-dev".
$ gulp
module.js:338
throw err;
^
Error: Cannot find module 'express-http-proxy'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/var/opt/jet/workspace/node-js-project/lib/authorization-to-context-header.js:1:75)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
installing the package
$ npm install express-http-proxy -g
express-http-proxy@0.6.0 /opt/jet/nodejs/node-js/lib/node_modules/express-http-proxy
âââ type-is@1.6.6 (media-typer@0.3.0, mime-types@2.1.4)
âââ raw-body@1.3.4 (bytes@1.0.0, iconv-lite@0.4.8)
or if the "-g" is not enough
$ npm install express-http-proxy --save-dev
gulp works
$ gulp
[16:49:17] Using gulpfile /var/opt/workspace/node-js-project/gulpfile.js
[16:49:17] Starting 'dev'...
[16:49:17] Starting 'clean'...
[16:49:17] Finished 'dev' after 9.18 ms
[16:49:17] Starting 'default'...
[16:49:17] Finished 'default' after 10 μs
[16:49:17] Finished 'clean' after 11 ms
[16:49:17] Starting 'build'...
[16:49:17] Starting 'clean'...
[16:49:17] Finished 'clean' after 2.13 ms
[16:49:17] Starting 'styles'...
[16:49:17] Finished 'styles' after 813 ms
...