我是nodejs的新手。我遇到了這個錯誤,現在我無法啓動我的npm。請讓我知道如何重新啓動NPM,以及如何從遇到此問題,以防止節點js錯誤。任何專家?
錯誤如下:
{ [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }
js-bson: Failed to load c++ bson extension, using pure JS version
C:\Users\sriramr\nodetest1\routes\index.js:129
collection.find({},{}function(e,docs){
^^^^^^^^
SyntaxError: Unexpected token function
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (C:\Users\sriramr\nodetest1\app.js:11:14)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs
\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v0.12.0
npm ERR! npm v2.5.1
npm ERR! code ELIFECYCLE
npm ERR! [email protected] start: `node ./bin/www`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script 'node ./bin/www'.
npm ERR! This is most likely a problem with the nodetest1 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node ./bin/www
npm ERR! You can get their info via:
npm ERR! npm owner ls nodetest1
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\sriramr\nodetest1\data\npm-debug.log
源代碼:: INDEX.JS
var express = require('express');
var router = express.Router();
router.get('/', function(req, res, next) {
res.render ('index',{title:'歡迎來到會議室演示。')}; });
router.get('/userlist', function(req, res) {
var db = req.db;
var collection = db.get('usercollection');
collection.find({},{},function(e,docs){
res.render('userlist', {
"userlist" : docs
});
});
});
router.get('/newuser',function(req,res){
res.render('newuser',{title:'Add new user'});
});
router.get('/newuser',function(req,res){
res.render('newroom',{title:'Add new room'});
});
router.post('/adduser', function(req, res) {
var db = req.db;
var userName = req.body.username;
var userEmail = req.body.useremail;
var collection = db.get('usercollection');
collection.insert({
"username" : userName,
"email" : userEmail
}, function (err, doc) {
if (err) {
res.send("There was a problem adding the information to the database.");
}
else {
res.redirect("userlist");
}
});
});
/*---------adding room number and room list -------*/
router.post('/addroom', function(req, res) {
var db = req.db;
var roomname = req.body.roomname;
var collection = db.get('roomlist');
collection.insert({
"roomname" : roomname
}, function (err, doc) {
if (err) {
res.send("There was a problem adding the information to the database.");
}
else {
res.redirect("roomlist");
}
});
});
/*----------room end list ------------------*/
/*--------addingtime list ----------*/
router.post('/addtime', function(req, res) {
var db = req.db;
var starttime = req.body.strt_time;
var endtime = req.body.end_time;
var emailid = req.body.empemail;
var collection = db.get('timelist');
collection.insert({
"starttime" : starttime,
"endtime" : endtime,
"emailid": emailid
}, function (err, doc) {
if (err) {
res.send("There was a problem adding the information to the database.");
}
else {
res.redirect("addtime");
}
});
var collection = db.get('roomlist');
collection.find({},{},function(e,docs){
res.render('roomlist', {
"roomname" : roomname
});
});
});
/*---------removing time list --------*/
/*----removing room number and roomlist -----------*/
router.post('/removeroom', function(req, res) {
var db = req.db;
var roomname = req.body.remove_room;
var collection = db.get('roomlist');
collection.remove({
"roomname" : roomname
}, function (err, doc) {
if (err) {
res.send("There was a problem adding the information to the database.");
}
else {
res.redirect("roomlist");
}
});
});
router.get('/roomlist', function(req, res) {
var db = req.db;
var collection = db.get('roomlist');
collection.find({},{}function(e,docs){
res.render('roomname', {
"roomname" : docs
});
});
});
/*----------end room number and room list ---------*/
/*--end db connection for user ---*/
module.exports = router;
你的代碼似乎有語法錯誤,發佈index.js的代碼 – Marged
@marged:DOne。請看看 –