简体   繁体   中英

npm start error mongodb/node_modules/bson

getting this error while running the command npm start

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'start' ]
2 info using npm@3.3.12
3 info using node@v5.4.1
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle passport-local@0.0.0~prestart: passport-local@0.0.0
6 silly lifecycle passport-local@0.0.0~prestart: no script for prestart, continuing
7 info lifecycle passport-local@0.0.0~start: passport-local@0.0.0
8 verbose lifecycle passport-local@0.0.0~start: unsafe-perm in lifecycle true
9 verbose lifecycle passport-local@0.0.0~start: PATH: C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;C:\Users\Rohil\Documents\ddbproject\passport-local\node_modules\.bin;C:\Users\Rohil\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\local\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\Rohil\bin;C:\oraclexe\app\oracle\product\11.2.0\server\bin;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client;C:\Program Files\Intel\iCLS Client;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;C:\Program Files\Java\jdk1.8.0_45\bin;C:\Program Files\nodejs;C:\mongodb\bin;C:\Users\Rohil\AppData\Local\Programs\Python\Python35-32;C:\Program Files\MongoDB\Server\3.2\bin;C:\Users\Rohil\AppData\Roaming\npm;C:\Program Files\MongoDB\Server\3.2\bin;C:\Program Files\Git\usr\bin\vendor_perl;C:\Program Files\Git\usr\bin\core_perl
10 verbose lifecycle passport-local@0.0.0~start: CWD: C:\Users\Rohil\Documents\ddbproject\passport-local
11 silly lifecycle passport-local@0.0.0~start: Args: [ '/d /s /c', 'node ./bin/www' ]
12 silly lifecycle passport-local@0.0.0~start: Returned: code: 1  signal: null
13 info lifecycle passport-local@0.0.0~start: Failed to exec start script
14 verbose stack Error: passport-local@0.0.0 start: `node ./bin/www`
14 verbose stack Exit status 1
14 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:232:16)
14 verbose stack     at emitTwo (events.js:87:13)
14 verbose stack     at EventEmitter.emit (events.js:172:7)
14 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:24:14)
14 verbose stack     at emitTwo (events.js:87:13)
14 verbose stack     at ChildProcess.emit (events.js:172:7)
14 verbose stack     at maybeClose (internal/child_process.js:821:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
15 verbose pkgid passport-local@0.0.0
16 verbose cwd C:\Users\Rohil\Documents\ddbproject\passport-local
17 error Windows_NT 10.0.10586
18 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
19 error node v5.4.1
20 error npm  v3.3.12
21 error code ELIFECYCLE
22 error passport-local@0.0.0 start: `node ./bin/www`
22 error Exit status 1
23 error Failed at the passport-local@0.0.0 start script 'node ./bin/www'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the passport-local package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error     node ./bin/www
23 error You can get their info via:
23 error     npm owner ls passport-local
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]

tried installing node-gyp and also cleaning cache, node_modules and running a fresh npm start

even then, i get an error saying module.js:327: throw err;

cannot find module 'mongodb/node_modules/bson'

my package.json file:

{
  "name": "passport-local",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "node ./bin/www"
  },
  "dependencies": {
    "body-parser": "^1.13.2",
    "chai": "~1.8.1",
    "cookie-parser": "^1.3.5",
    "express": "^4.13.1",
    "express-session": "^1.10.1",
    "jade": "^1.11.0",
    "mocha": "~1.14.0",
    "mongoose": "^3.8.22",
    "morgan": "^1.6.1",
    "passport": "^0.2.1",
    "passport-local": "^1.0.0",
    "passport-local-mongoose": "^1.0.0",
    "should": "~2.1.0",
    "serve-favicon": "^2.2.0",
    "debug": "^2.1.1"
  }
}

after running the command npm link mongodb and then running npm start, im getting a new error:

    { [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }
js-bson: Failed to load c++ bson extension, using pure JS version
events.js:141
      throw er; // Unhandled 'error' event
      ^

Error: failed to connect to [localhost:27017]
    at null.<anonymous> (C:\Users\Rohil\Documents\ddbproject\passport-local\node_modules\mongoose\node_modules\mongodb\lib\mongodb\connection\server.js:556:25)
    at emitThree (events.js:97:13)
    at emit (events.js:175:7)
    at null.<anonymous> (C:\Users\Rohil\Documents\ddbproject\passport-local\node_modules\mongoose\node_modules\mongodb\lib\mongodb\connection\connection_pool.js:156:15)
    at emitTwo (events.js:87:13)
    at emit (events.js:172:7)
    at Socket.<anonymous> (C:\Users\Rohil\Documents\ddbproject\passport-local\node_modules\mongoose\node_modules\mongodb\lib\mongodb\connection\connection.js:534:10)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at emitErrorNT (net.js:1255:8)
    at nextTickCallbackWith2Args (node.js:474:9)
    at process._tickCallback (node.js:388:17)

npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v5.4.1
npm ERR! npm  v3.3.12
npm ERR! code ELIFECYCLE
npm ERR! passport-local@0.0.0 start: `node ./bin/www`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the passport-local@0.0.0 start script 'node ./bin/www'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the passport-local 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 passport-local
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\Rohil\Documents\ddbproject\passport-local\npm-debug.log

the contents of the ./bin/www file are:

#!/usr/bin/env node

/**
 * Module dependencies.
 */

var app = require('../app');
var debug = require('debug')('passport-local:server');
var http = require('http');

/**
 * Get port from environment and store in Express.
 */

var port = normalizePort(process.env.PORT || '3000');
app.set('port', port);

/**
 * Create HTTP server.
 */

var server = http.createServer(app);

/**
 * Listen on provided port, on all network interfaces.
 */

server.listen(port);
server.on('error', onError);
server.on('listening', onListening);

/**
 * Normalize a port into a number, string, or false.
 */

function normalizePort(val) {
  var port = parseInt(val, 10);

  if (isNaN(port)) {
    // named pipe
    return val;
  }

  if (port >= 0) {
    // port number
    return port;
  }

  return false;
}

/**
 * Event listener for HTTP server "error" event.
 */

function onError(error) {
  if (error.syscall !== 'listen') {
    throw error;
  }

  var bind = typeof port === 'string'
    ? 'Pipe ' + port
    : 'Port ' + port;

  // handle specific listen errors with friendly messages
  switch (error.code) {
    case 'EACCES':
      console.error(bind + ' requires elevated privileges');
      process.exit(1);
      break;
    case 'EADDRINUSE':
      console.error(bind + ' is already in use');
      process.exit(1);
      break;
    default:
      throw error;
  }
}

/**
 * Event listener for HTTP server "listening" event.
 */

function onListening() {
  var addr = server.address();
  var bind = typeof addr === 'string'
    ? 'pipe ' + addr
    : 'port ' + addr.port;
  debug('Listening on ' + bind);
}

This issue started after editing my app.js file:

// dependencies
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var mongoose = require('mongoose');
var passport = require('passport');
var LocalStrategy = require('passport-local').Strategy;
var routes = require('./routes/index');
var users = require('./routes/users');
var app = express();
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
// uncomment after placing your favicon in /public
//app.use(favicon(__dirname + '/public/favicon.ico'));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(require('express-session')({
    secret: 'keyboard cat',
    resave: false,
    saveUninitialized: false
}));
app.use(passport.initialize());
app.use(passport.session());
app.use(express.static(path.join(__dirname, 'public')));


app.use('/', routes);

// passport config
var Account = require('./models/account');
passport.use(new LocalStrategy(Account.authenticate()));
passport.serializeUser(Account.serializeUser());
passport.deserializeUser(Account.deserializeUser());

// mongoose
mongoose.connect('mongodb://localhost/passport_local_mongoose_express4');

// catch 404 and forward to error handler
app.use(function(req, res, next) {
    var err = new Error('Not Found');
    err.status = 404;
    next(err);
});

// error handlers

// development error handler
// will print stacktrace
if (app.get('env') === 'development') {
    app.use(function(err, req, res, next) {
        res.status(err.status || 500);
        res.render('error', {
            message: err.message,
            error: err
        });
    });
}

// production error handler
// no stacktraces leaked to user
app.use(function(err, req, res, next) {
    res.status(err.status || 500);
    res.render('error', {
        message: err.message,
        error: {}
    });
});

module.exports = app;

also created a new file /models/account.js:

var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var passportLocalMongoose = require('passport-local-mongoose');

var Account = new Schema({
    username: String,
    password: String
});

Account.plugin(passportLocalMongoose);

module.exports = mongoose.model('Account', Account);

any errors in that?

mongo refuses to start too

$ mongo
MongoDB shell version: 3.2.1
connecting to: test
2016-02-20T23:34:10.083+0530 W NETWORK  [thread1] Failed to connect to 127.0.0.1:27017, reason: errno:10061 No connection could be made because the target machine actively refused it.
2016-02-20T23:34:10.084+0530 E QUERY    [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:224:14
@(connect):1:6

exception: connect failed

The mongoose error might be due to unstable version of mongoose, update "mongoose": "3.8" in package.json. (Followed by npm install ) This might remove mongoose warning.

Check this link for Failed to load c++ extension

Made sure these two packages are at these versions "mongodb": "^2.1.16", "mongoose": "^4.4.12"

And running the below commands with reference to here

npm install node-gyp -g npm cache clean rm -rf node_modules npm install

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM