简体   繁体   English

错误:在Mac上找不到模块'../build/Release/bson'

[英]Error: Cannot find module '../build/Release/bson' on Mac

I am using node.js to run one app given by my professor on my chrome. 我正在使用node.js运行我的教授在我的chrome上给出的一个应用程序。 Something wrong happen, but I don't know because I am a rookie. 发生了一些错事,但我不知道,因为我是一名新秀。 The structure is as follows: 结构如下:

/app
   /models
      answers.js
      questions.js
      sessions.js
      user.js
   passport.js
   qmanage.js
   routes.js
/config
   auth.js
   database.js
   mcd.js
package.json
/public
   some css png fonts jpg document
qloader.js
server.js
/views
   some ejs document

At first, it shows this problem: 首先,它显示了这个问题:

module.js:457
    throw err;
    ^

Error: Cannot find module 'mongoose'
    at Function.Module._resolveFilename (module.js:455:15)
    at Function.Module._load (module.js:403:25)
    at Module.require (module.js:483:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/shen/Desktop/os/cse303.p2/server.js:2:16)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)

then, based on this help Node.js error Error: Cannot find module 'mongoose' I run npm install mongoose in my root path of project. 那么,基于这个帮助Node.js错误错误:找不到模块'mongoose'我在项目的根路径中运行npm install mongoose Then I have those error below: 然后我有以下错误:

dyn143030:cse shen$ node server.js 
{ Error: Cannot find module '../build/Release/bson'
    at Function.Module._resolveFilename (module.js:455:15)
    at Function.Module._load (module.js:403:25)
    at Module.require (module.js:483:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/shen/Desktop/os/cse303.p2/node_modules/bson/ext/index.js:15:10)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3) code: 'MODULE_NOT_FOUND' }
js-bson: Failed to load c++ bson extension, using pure JS version
events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: Invalid mongodb uri. Missing hostname
    at muri (/Users/shen/Desktop/os/cse303.p2/node_modules/muri/lib/index.js:40:11)
    at NativeConnection.Connection.open (/Users/shen/Desktop/os/cse303.p2/node_modules/mongoose/lib/connection.js:195:16)
    at Mongoose.connect (/Users/shen/Desktop/os/cse303.p2/node_modules/mongoose/lib/index.js:212:15)
    at Object.<anonymous> (/Users/shen/Desktop/os/cse303.p2/server.js:4:10)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)
    at Module.runMain (module.js:590:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:509:3

I tried to find solution from this help Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' } js-bson: Failed to load c++ bson extension, using pure JS version but it seems not my case, because I am using OS X 10.11.3 我试图从这个帮助找到解决方案无法找到模块'../build/Release/bson']代码:'MODULE_NOT_FOUND'} js-bson:无法加载c ++ bson扩展,使用纯JS版本,但似乎不是我的情况,因为我使用的是OS X 10.11.3

dyn143030:cse shen$ node -v
v6.5.0
dyn143030:cse shen$ npm -v
3.10.3

From my aspect, I think the system find bson someplace wrong, so how to modify it? 从我的角度来看,我认为系统发现某个地方错了,所以如何修改呢? Thanks! 谢谢! If any more information is need, please tell me. 如果需要更多信息,请告诉我。

I find in node_modules\\bson\\ext\\index.js 我在node_modules \\ bson \\ ext \\ index.js中找到

and change path on 10th line 并在第10行更改路径

bson = require('../build/Release/bson'); to bson = require('bson'); to bson = require('bson');

您可以尝试将mongoose添加到package.json文件中的依赖项列表中,或者也可以在项目文件夹中执行> npm install mongoose。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 MongoDB - 错误:无法找到模块&#39;../build/Release/bson&#39; - MongoDB - Error: Cannot find module '../build/Release/bson' Microsoft NodeJS从零到英雄:找不到模块&#39;../build/Release/bson&#39;和TypeError:无法读取未定义的属性&#39;indexOf&#39; - Microsoft NodeJS Zero to Hero: Cannot find module '../build/Release/bson' and TypeError: Cannot read property 'indexOf' of undefined 错误:找不到模块“./build/Release/sharp” - Error: Cannot find module './build/Release/sharp' 找不到模块 &#39;../build/Release/bson&#39;] 代码:&#39;MODULE_NOT_FOUND&#39; } js-bson:无法加载 c++ bson 扩展,使用纯 JS 版本 - Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' } js-bson: Failed to load c++ bson extension, using pure JS version Vogels错误:错误:找不到模块&#39;./build/Release/DTraceProviderBindings&#39; - Vogels err: Error: Cannot find module './build/Release/DTraceProviderBindings' Rocket.Chat构建失败,错误为“找不到模块&#39;../build/Release/sharp.node&#39;” - Rocket.Chat build failing with error “Cannot find module '../build/Release/sharp.node' ” 找不到模块'../build/Release/opencv4nodejs - Cannot find module '../build/Release/opencv4nodejs 运行节点脚本时出错,找不到模块&#39;mongodb / node_modules / bson&#39; - Error when running node script , Cannot find module 'mongodb/node_modules/bson' 使用Browserify构建npm-错误:找不到模块 - npm build with Browserify - Error: Cannot find module 找不到模块&#39;mongodb / node_modules / bson&#39; - Cannot find module 'mongodb/node_modules/bson'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM