我想按照這個教程: http://cwbuecheler.com/web/tutorials/2014/restful-web-app-node-express-mongodb/
我有一個蒙戈數據庫上的另一個Linux機器上運行...和fwiw,我知道它的工作原理是因爲我有一個可以連接和查詢的php應用程序。
我不使用貓鼬......但和尚,因爲這是教程要求。
這是我的package.json文件看起來是這樣的:
{
"name": "testapp",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www"
},
"dependencies": {
"body-parser": "~1.13.2",
"cookie-parser": "~1.3.5",
"debug": "~2.2.0",
"express": "~4.13.1",
"mongodb": "^1.4.4",
"monk": "^1.0.1",
"morgan": "~1.6.1",
"pug": "^2.0.0-beta4",
"serve-favicon": "~2.3.0"
}
}
〜
問題
當我嘗試運行測試節點的應用程序,我發現了以下錯誤消息:
[email protected]:/var/www/html/node/testapp$ node app.js
{ Error: Cannot find module '../build/Release/bson'
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> (/var/www/html/node/testapp/node_modules/mongodb/node_modules/bson/ext/index.js:15:10)
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) code: 'MODULE_NOT_FOUND' }
js-bson: Failed to load c++ bson extension, using pure JS version
這是index.js文件的樣子:
3 try {
4 // Load the precompiled win32 binary
5 if(process.platform == "win32" && process.arch == "x64") {
6 bson = require('./win32/x64/bson');
7 } else if(process.platform == "win32" && process.arch == "ia32") {
8 bson = require('./win32/ia32/bson');
9 } else {
10 bson = require('../build/Release/bson');
11 }
12 } catch(err) {
13 // Attempt to load the release bson version
14 try {
15 bson = require('../build/Release/bson');
16 } catch (err) {
17 console.dir(err)
18 console.error("js-bson: Failed to load c++ bson extension, using pure JS version");
19 bson = require('../lib/bson/bson');
20 }
21 }
我試了一下:
根據對stackoverflow.com其他職位,我想換線15看起來像這樣:
15 bson = require('bson');
我也試着運行以下命令:
sudo npm install bson
但這並沒有解決問題。
萬一有幫助,我做了搜索我的盒子 「BSON」,並與這些結果出來了:http://pastebin.com/WKQygGak
系統信息
的Ubuntu 15.10
編輯1
[email protected]:/var/www/html/node/testapp$ sudo apt-get install gcc make build-essential
Reading package lists... Done
Building dependency tree
Reading state information... Done
build-essential is already the newest version.
gcc is already the newest version.
make is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
然後我跑了foll由於命令:
有似乎已經在第10行的錯誤,但我不知道如何糾正它。
EDIT 2
這是我目前在我的NPM配置:
[email protected]:/var/www/html/node/testapp$ npm config list
; cli configs
user-agent = "npm/3.10.3 node/v6.3.1 linux x64"
; userconfig /home/me/.npmrc
https-proxy = "http://10.1.1.11:8080/"
proxy = "http://10.1.1.11:8080/"
python = "python2.7"
; globalconfig /usr/etc/npmrc
; node bin location = /usr/bin/nodejs
; cwd = /var/www/html/node/testapp
; HOME = /home/me
; "npm config ls -l" to show all defaults.
[email protected]:/var/www/html/node/testapp$
另外,作爲一個測試,我想只是爲了「命令故宮安裝BSON」,也未能與我在發佈的pastebin中看到了同樣的錯誤。
嗨。請再次參閱編輯1的答案 – Happydevdays
的詳細結果。是的...我已經嘗試過...我已經爲你發佈我的配置。請參閱編輯2. – Happydevdays
@Happydevdays是你的路徑中的蟒蛇?通過輸入python可以在終端中使用路徑嗎? –