我想按照這個tutorial,我無法運行,因爲這個錯誤的節點服務器:無法啓動節點服務器,問題與mongodb數據庫?
TypeError: Cannot read property 'name' of undefined at makeSkinClass
這裏是我的路徑:
echo $PATH /usr/local/mysql/bin:/mongodb/bin:Users/Empon/npm/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/bin
我想通了,-g
在我的終端永遠不會奏效,所以我試圖永久地將路徑添加到PATH中,我將mongodb添加到bashrc和bash_profile中。
然後我做了npm install -g mongodb
,我有這樣的:
[email protected] requires a peer of [email protected]~0.0 but none was installed.
所以我添加npm install --save kerberos mongodb
,結果是:現在
npm WARN skippingAction Module is inside a symlinked module: not running remove [email protected] node_modules/mongodb/node_modules/bson npm WARN skippingAction Module is inside a symlinked module: not running remove [email protected]
,在我的節點項目,我做的:node bin/www
啓動服務器(我試過節點app.js,在配置文件中有「app.js」,但它沒有工作,所以我讓./bin/www
),URL是:http://localhost:3000/api/videos
。
你知道什麼是錯的嗎?
編輯: 我得到它的工作,與這些操作:安裝MongoDB中的舊版本,並改變在配置文件中的一行:
Does run mongoskin only with mongodb version 1.4 and older?
我幾乎在那裏,到端口的網址工作正常(http://localhost:3000/),但不是一個爲mongodb(http://localhost:3000/api/videos),錯誤是:
Error: Not Found at /Applications/MAMP/htdocs/workspace/Vidzy/app.js:32:13 at Layer.handle [as handle_request] (/Applications/MAMP/htdocs/workspace/Vidzy/node_modules/express/lib/router/layer.js:95:5) at trim_prefix (/Applications/MAMP/htdocs/workspace/Vidzy/node_modules/express/lib/router/index.js:312:13)
而且我的代碼是:
//in routes/video.js
var express = require('express');
var router = express.Router();
var monk = require('monk');
var db = monk('localhost:27017/vidzy');
router.get('/', function(req, res){
var collection = db.get('videos');
collection.find({}, function(err, videos){
if (err) throw err;
res.json(videos);
});
});
module.exports = router;
//in app.js
// catch 404 and forward to error handler
app.use(function(req, res, next) {
var err = new Error('Not Found');
err.status = 404;
next(err);
});
終端連接到MongoDB的:
I NETWORK [initandlisten] waiting for connections on port 27017
會有人知道我爲什麼會得到一個404,以及如何調試呢?
這似乎是你缺少必要的模塊。也許在應用程序目錄中重新運行'npm install mongoskin --save'來確保。在安裝依賴關係時,不要忘記使用'--save'或'--save-dev'。 –
嘗試按照這種解決方案https://github.com/kissjs/node-mongoskin/issues/153#issuecomment-85740639 – Maxali
@PeteGarafano感謝,我發現了2個網址,我發佈瞭解決方案,但我的網頁還沒有工作,你能看看我的編輯嗎? – Paul