简体   繁体   中英

Node js - Error: spawn ENOENT (Windows 8.1)

I'm using nodejs version - v0.10.31

On one machine it does work, and on my machine it doesn't. Can someone give me some advice where I can start searching for a problem ?

var express = require('express'),
path = require('path'),
fs = require('fs'),
mongoose = require('mongoose'),
expressSession = require("express-session");

var env = process.env.NODE_ENV = process.env.NODE_ENV || "development";

var config = require('./server/config/config')[env];

var app = express();
var server = app.listen(config.port);

var sessionMiddleware = expressSession({
    name: "dga-cookie",
    secret: "dga-secret",
    store: new (require("connect-mongo")(expressSession))({
        url: config.db,
        auto_reconnect: true
    }),
    saveUninitialized: true,
    resave: true
});

app.use(sessionMiddleware);

var io = require('socket.io')(server);

io.use(function(socket, next){
    sessionMiddleware(socket.request, {}, next);
});

require('./server/config/express')(app, config);

require('./server/config/mongoose')(config);

/* user schema */
var userSchema = mongoose.Schema({
    username: {type: String, required: true, unique: true},
    email: {type: String, required: true, unique: true},
    password: {type: String, required: true},
    activated: {type: Boolean, required: true}
});

var User = mongoose.model('users', userSchema);

require('./server/config/routes')(app);

require('./server/config/rest/user')(app, io, User);

require('./server/config/rest/game')(app, io, User);

and there is the package.json:

{
  "name": "app",
  "version": "0.0.1",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/..."
  },
  "author": "",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/..."
  },
  "homepage": "https://github.com/...",
  "dependencies": {
    "body-parser": "~1.5.0",
    "compass": "~0.1.0",
    "connect-mongo": "~0.4.1",
    "cookie-parser": "~1.3.2",
    "express": "~4.6.1",
    "express-session": "~1.7.0",
    "jade": "~1.4.2",
    "mongoose": "~3.8.13",
    "morgan": "~1.2.0",
    "node-compass": "^0.2.3",
    "passport": "~0.2.0",
    "passport-local": "~1.0.0",
    "sha1": "^1.1.0"
  },
  "devDependencies": {
    "bower": "~1.3.8",
    "socket.io": "~1.0.6"
  }
}
$ nodemon server
15 Sep 20:51:36 - [nodemon] v1.2.1
15 Sep 20:51:36 - [nodemon] to restart at any time, enter `rs`
15 Sep 20:51:36 - [nodemon] watching: *.*
15 Sep 20:51:36 - [nodemon] starting `node server`
DGE db opened
GET / 304 626.838 ms - -

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: spawn ENOENT
    at errnoException (child_process.js:1001:11)
    at Process.ChildProcess._handle.onexit (child_process.js:792:34)
15 Sep 20:51:45 - [nodemon] app crashed - waiting for file changes before starting...

I also got the same error on Windows 8.1. The error is because of an environment variable of your system path missing "C:\\Windows\\System32\\" value. So go to My Computer right click, go to the Properties->Advanced System Setting->Environment variable. Now open(Edit) "PATH" variable and add "C:\\Windows\\System32\\" value into the value filed of the path variable. Save all changes. Now close your Node.js cmd prompt and reopen it. Now type nodemon cmd. Hope it will work for you.

This is happening after a GET request. I'd look into your routing file and see what files are being used within that context.

i suggest you check if mongodb is installed on the machine (the executable, not the npm). this error often occurs when node tries to execute a program that does not exist.

good luck!

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