Error: Cannot find module 'connect'

后端 未结 8 1691
孤街浪徒
孤街浪徒 2021-02-19 21:27

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         


        
8条回答
  •  耶瑟儿~
    2021-02-19 22:06

    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. (/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
    ...
    

提交回复
热议问题