Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

express js fail, after npm start #31

Closed
szmarci opened this issue Jun 9, 2014 · 23 comments
Closed

express js fail, after npm start #31

szmarci opened this issue Jun 9, 2014 · 23 comments
Labels

Comments

@szmarci
Copy link

szmarci commented Jun 9, 2014

Hi,

I tried to run the generator, but run into some errors.
(I'm on OS X 10.9.2, node, npm, express, everything is the latest)
There are no problems until npm start I get this in the prompt:

> express@0.0.1 start /Users/szmarci/Sites/express
> node ./bin/www

Then I visit http://localhost:3000/, I get the Express test page (but unstyled) and immediately after this in the terminal:

GET / 304 982ms

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: spawn ENOENT
    at errnoException (child_process.js:998:11)
    at Process.ChildProcess._handle.onexit (child_process.js:789:34)

npm ERR! express@0.0.1 start: `node ./bin/www`
npm ERR! Exit status 8
npm ERR!
npm ERR! Failed at the express@0.0.1 start script.
npm ERR! This is most likely a problem with the express 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 express
npm ERR! There is likely additional logging output above.
npm ERR! System Darwin 13.1.0
npm ERR! command "node" "/usr/local/bin/npm" "start"
npm ERR! cwd /Users/szmarci/Sites/express
npm ERR! node -v v0.10.28
npm ERR! npm -v 1.4.9
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/szmarci/Sites/express/npm-debug.log
npm ERR! not ok code 0

I couldn't find any solution with google, tried to sudo, change port, etc.. but no luck.

@jonathanong
Copy link
Member

just type npm start

@szmarci
Copy link
Author

szmarci commented Jun 10, 2014

There are no problems until npm start, I get this in the prompt:

I did type npm start. But then, when I visit http://localhost:3000 the whole thing quits with the error message I quoted above.

@dougwilson
Copy link
Contributor

@szmarci what is the output for the following command: which node?

@szmarci
Copy link
Author

szmarci commented Jun 10, 2014

it's /usr/local/bin/node
update: I don't know if it makes a difference but prior to installing node I changed ownership of the /usr/local folder, so I don't have to sudo everytime I install something

@dougwilson
Copy link
Contributor

It shouldn't. I asked because the error you posed says that when npm tried to run node ./bin/www, it couldn't fine any binary called node in $PATH.

@szmarci
Copy link
Author

szmarci commented Jun 11, 2014

well, node works just fine. do you have any idea what else can I try?

@dougwilson
Copy link
Contributor

I have no idea, I'm sorry. It may be worth asking on npm issue tracker, or try to debug the error since I cannot reproduce it.

@szmarci
Copy link
Author

szmarci commented Jun 12, 2014

I will try to reinstall everything, node, npm, express and I'll come back with the result.

@szmarci
Copy link
Author

szmarci commented Jun 17, 2014

so I did reinstall everything, node, npm, express, etc... and for some strange reason it seems it is now working. after npm start I get this:

> node ./bin/www

GET / 304 573ms
GET /stylesheets/style.css 304 2ms
GET / 304 35ms
GET /stylesheets/style.css 304 40ms

after there is a spinning backslash and localhost:3000 shows the test page correctly.
I have no idea what was wrong. maybe because node bumped from 10.28 to 10.29 ?

@dougwilson
Copy link
Contributor

and for some strange reason it seems it is now working

ok, i'm going to close this issue.

after there is a spinning backslash

the node.js 0.10.29 comes with a broken npm in this regard; if you don't want to see that spinner you'll have to upgrade your npm.

@draschke
Copy link

"I will try to reinstall everything, node, npm, express and I'll come back with the result."

@szmarci
I think I've similar problems as you had.
How did you reinstalled all this stuff, especially express?

@szmarci
Copy link
Author

szmarci commented Aug 22, 2014

@draschke sorry for the late reply. I followed the instructions in this answer for node and npm.
for express I don't remember exactly, but I might just used npm uninstall or I removed the executable directly.

@draschke
Copy link

:)
Thank you!

@renfeisong
Copy link

I encountered this issue and finally get it solved by running the following command:

$ gem update --system
$ gem install compass

source: Vigrond

@carlosbaraza
Copy link

@renfeisong thank you.

Indeed, I had the same issue and was due to a missing installation of Compass. Just running gem install compass solved the issue.

Thanks!

@freealex
Copy link

freealex commented May 9, 2015

I'm running Node.js on windows 8, and when I'm encountering the same/similar issue. I follow these steps and it works perfectly until Iry :

    C:\node\nodetest>npm start
    app.use.(function(req,res,next) {
    TypeError: Cannot read property 'use' of undefined
        at Object.<anonymous> {C:\node\nodetest\app.js:19:4)
        at Module._compile (module.js:460:26)
        at Object.Module._estiensions..js (module.js:478:10
        at Module.load (module.js:355:17)
        at require (module.js:365:17)
        at Object.<anonymous> (C:\node\nodetest\bin\www:7:11)
        at Module._compile (module.js:460:26)
        at Obeject.Module._extensions..js (module.js:478:10)

   npm ERR! Windows_NT 6.3.9600
   npm ERR! argv "C:\\Program Files\node.js\\\\node.exe" "C:\\Program Files\\node.js
   \\node_modules\\npm\\bin\\npm-cli.js" "start"
    npm ERR! node v0.12.2
    npm ERR! npm  v2.7.4
    npm ERR! ELIFECYCLE
    npm ERR!  nodetest@0.0.0 start 'node ./bin/www',
    npm ERR!  Exit status 1
    npm ERR!
    npm ERR! Failed at the nodetest@0.0.0 start script 'node./bin/www'
    npm This is most likely a problem with the nodetest package, not with npm itself
AND this is my debug log:
    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@2.7.4
    3 info using node@v0.12.2
    4 verbose node symlink C:\Program Files\nodejs\\node.exe
    5 verbose run-script [ 'prestart', 'start', 'poststart' ]
    6 info prestart nodetest3@0.0.0
    7 info start nodetest3@0.0.0
    8 verbose unsafe-perm in lifecycle true
    9 info nodetest3@0.0.0 Failed to exec start script
    10 verbose stack Error: nodetest3@0.0.0 start: `node ./bin/www`
    10 verbose stack Exit status 1
    10 verbose stack     at EventEmitter.<anonymous> (C:\Program   
     Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:213:16)
    10 verbose stack     at EventEmitter.emit (events.js:110:17)
    10 verbose stack     at ChildProcess.<anonymous> (C:\Program    
     Files\nodejs\node_modules\npm\lib\utils\spawn.js:14:12)
    10 verbose stack     at ChildProcess.emit (events.js:110:17)
    10 verbose stack     at maybeClose (child_process.js:1015:16)
    10 verbose stack     at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
    11 verbose pkgid nodetest3@0.0.0
    12 verbose cwd C:\node\nodetest3
    13 error Windows_NT 6.3.9600
    14 error argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program         
     Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
    15 error node v0.12.2
    16 error npm  v2.7.4
    17 error code ELIFECYCLE
    18 error nodetest3@0.0.0 start: `node ./bin/www`
    18 error Exit status 1
    19 error Failed at the nodetest3@0.0.0 start script 'node ./bin/www'.
    19 error This is most likely a problem with the nodetest3 package,
    19 error not with npm itself.
    19 error Tell the author that this fails on your system:
    19 error     node ./bin/www
    19 error You can get their info via:
    19 error     npm owner ls nodetest3
    19 error There is likely additional logging output above.
    20 verbose exit [ 1, true ]

This is my app.js where the 'use' function is being called:

     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 routes = require('./routes/index');
    var users = require('./routes/users');








    /// catch 404 and forwarding 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
            });
        });
    }


var app = express();

// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');

//
    app.use(favicon(__dirname + '/public/favicon.ico'));
    app.use(logger('dev')); 
    app.use(bodyParser.json());
    app.use(bodyParser.urlencoded());
    app.use(cookieParser());
    app.use(express.static(path.join(__dirname, 'public')));

    app.use('/', routes);
    app.use('/users', users);





    // 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: {}
        });
    });

I'm just getting 'into cmd'' and really enjoy it, so sorry if my syntax/phrasing or anything makes this impossible to sort through in order to give advice (this is my first post to github).

@dougwilson
Copy link
Contributor

@ADC5 you need to put the line var app = express(); above when you first try to use the app variable (i.e. move that line above /// catch 404 and forwarding to error handler).

@freealex
Copy link

freealex commented May 9, 2015

@dougwilson Thanks for that doug! But when I call npm start it gives me another set of errors:

    rfs.js.:797
        return binding.stat(pathModule._makeLong(path));
    Error:  ENOENT, no such file or directory 'filepath'
        at Error (native)
        at Object.fs.statsSync (fs.js:797:18)
        at favicon ('path to favicon')
        at Object.<anonymous> (C:\node\nodetest\app.js:49:9)   
        at Module._compile (module.js:460:26)
        at Object.Module._extensions..js (module.js:478:10)
        at Module.load (module.js:365:17)
        at Module.require (module.js.:365:17)
        at require (module.js:384:17)

And then the rest of the ERR! statements are the same. Any other ideas? Also, is there a way to copy the text from node.js so I don't have to type it completely out each time? Thanks again for the help!

@dougwilson
Copy link
Contributor

@ADC5 it's because you do not have a file at public/favicon.ico. You either need to put one there, or comment out that line.

@freealex
Copy link

freealex commented May 9, 2015

I tried that and it gave me:
body-parser deprecated undefined extended option app.js
C:\node\node\nodetest\bin\www:16 (line 16 is blank in app.js)
aopp.set('port', port);

@freealex
Copy link

freealex commented May 9, 2015

app.set('port',port);  

Sorry, accidently sent that while I was finishing it. Could that mean I have a server connection issue>

@freealex
Copy link

freealex commented May 9, 2015

and I forgot the @dougwilson : 2 previous posts

@dougwilson
Copy link
Contributor

@ADC5 I'm happy to help more, but please, let's stop filling the dozen people in this old thread's email inboxes. Please create a new issue here: https://github.com/expressjs/generator/issues/new

@expressjs expressjs locked and limited conversation to collaborators May 9, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

7 participants