javascript - 找不到模块 'mongodb/node_modules/bson'

标签 javascript node.js mongodb

这些是我从目录 sangam 运行 grunt serve 命令后得到的结果

C:\Users\Rohit\Documents\GitHub\sangam>grunt serve
Running "serve" task

Running "clean:server" (clean) task

Running "env:all" (env) task

Running "concurrent:server" (concurrent) task

Running "injector:scripts" (injector) task
Missing option `template`, using `dest` as template instead
Injecting js files (14 files)
>> Nothing changed

Running "injector:css" (injector) task
Missing option `template`, using `dest` as template instead
Injecting css files (5 files)
>> Nothing changed

Running "wiredep:target" (wiredep) task

Running "autoprefixer:dist" (autoprefixer) task

Running "express:dev" (express) task
Starting background Express server
Debugger listening on port 5858
module.js:327
    throw err;
    ^

Error: Cannot find module 'mongodb/node_modules/bson'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (C:\Users\Rohit\Documents\GitHub\sangam\node_modules\mongoose\lib\drivers\node-mongodb-native\objectid.js:8:16)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)

Running "wait" task
>> Waiting for server reload...
Done waiting!

Running "open:server" (open) task

Running "watch" task
Waiting...

运行 grunt serve 后,我得到了那个错误

"cannot find module 'mongodb/node_modules/bson'" ,

本地主机页面打开,但我得到“无法访问此页面”,请帮我解决这个问题

最佳答案

github-issue 中所写尝试执行以下步骤:-

Make sure these two packages are at these versions

"mongodb": "^2.1.16", "mongoose": "^4.4.12"

npm install -g node-gyp 
cd /to/your/project-folder
rm -rf node_modules
npm install

也尝试做:-

do npm install inside node_modules/mongodb.

希望对您有所帮助。

关于javascript - 找不到模块 'mongodb/node_modules/bson',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37654497/

相关文章:

javascript - 通过shadow root进行突破注入(inject)

javascript - socket.io 发送消息两次

javascript - NodeJS : Execute a function when UTC server time equals to time entry in firebase database

c++ - 如何为其构造函数采用右值的类声明变量?

javascript - XMLHttpRequest 'response' 参数为空

javascript - jQuery 删除文本区域中的电子邮件

node.js - 如何卸载从 pkg (Mac OS X) 安装的 nodejs?

node.js - 无法加载资源: the server responded with a status of 404 (Not Found) - Ionic2

ruby - 为什么\xF3不被识别为UTF-8

node.js - 如何使用 mongoosastic 连接到 AWS Elasticsearch