monk-Error: Cannot find module &

2016-05-26  本文已影响2337人  real勾玉

今天新建了新的项目,用node 6.2.0安装了下monk包,连接mongodb后报错如下:

Error: Cannot find module 'mongodb'
    at Function.Module._resolveFilename (module.js:440:15)
    at Function.Module._load (module.js:388:25)
    at Module.require (module.js:468:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/zyy/github/fete/node_modules/mongoskin/lib/index.js:14:13)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Module.require (module.js:468:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/zyy/github/fete/node_modules/mongoskin/index.js:1:132)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)

看了下npm install log

npm WARN mongoskin@1.4.13 requires a peer of mongodb@~1.4 but none was installed.

mongoskin依赖的mongodb没有安装,把以前的项目扒出来,使用的mongodb是1.4.39,安装完后又出现下面问题:

Starting child process with 'node --harmony server.js'
/Users/zyy/github/fete/node_modules/mongoskin/lib/utils.js:33
  var skinClassName = 'Skin' + NativeClass.name;
                                          ^

TypeError: Cannot read property 'name' of undefined
    at makeSkinClass (/Users/zyy/github/fete/node_modules/mongoskin/lib/utils.js:33:43)
    at Object.<anonymous> (/Users/zyy/github/fete/node_modules/mongoskin/lib/grid.js:6:35)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Module.require (module.js:468:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/zyy/github/fete/node_modules/mongoskin/lib/db.js:22:16)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)Program node --harmony server.js exited with code 1

看了下https://github.com/Automattic/monk/issues/91
改成1.4.4,在当前项目的目录中执行:

npm install mongodb@1.4.4

现在只能这样解决了....
期待您的方案

上一篇下一篇

猜你喜欢

热点阅读