Blog coding and discussion of coding about JavaScript, PHP, CGI, general web building etc.

Saturday, June 18, 2016

npm start looking for /bin/www in the wrong directory, how to update

npm start looking for /bin/www in the wrong directory, how to update


So I'm following This Tutorial here to get a personal/learning node.js project off the ground that I would like to work on and store in GitHub and eventually put onto a live server or cloud hosting. It's using node.js, express, monk, mongoDB for a website setup. However I have a persistent error that I haven't found an answer to when I run 'npm start'.

Here is my command window output when I try to run 'npm start' inside my node express project.

I know that: Error: Cannot find module 'C:\Users\username\Desktop\bin\www' is not where my bin\www is located (it's inside the nodetest1 project).

C:\Users\username\Documents\GitHub\TEDResources\node.js\nodetest1 <-- correct path

So, why is npm looking at that incorrect spot and how do I update it to correctly look at my project folder? I've searched my system and can't find module.js anywhere. (using windows 7 x64) I've also tried nuking node.js and express and started from scratch without luck.

//console error output

Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation. All rights reserved. C:\Users\username\Documents\GitHub\TEDResources\node.js\nodetest1>npm start

> nodetest1@0.0.0 start C:\Users\username\Documents\GitHub\TEDResources\node.j  s\nodetest1    > node ./bin/www  module.js:340      throw err;            ^  Error: Cannot find module 'C:\Users\username\Desktop\bin\www'      at Function.Module._resolveFilename (module.js:338:15)      at Function.Module._load (module.js:280:25)      at Function.Module.runMain (module.js:497:10)      at startup (node.js:119:16)      at node.js:906:3    npm ERR! nodetest1@0.0.0 start: `node ./bin/www`  npm ERR! Exit status 8  npm ERR!  npm ERR! Failed at the nodetest1@0.0.0 start script.  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! System Windows_NT 6.1.7601  npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nod  ejs\\node_modules\\npm\\bin\\npm-cli.js" "start"  npm ERR! cwd C:\Users\username\Documents\GitHub\TEDResources\node.js\nodetest1    npm ERR! node -v v0.10.32  npm ERR! npm -v 1.4.28  npm ERR! code ELIFECYCLE  npm ERR!  npm ERR! Additional logging details can be found in:  npm ERR!     C:\Users\username\Documents\GitHub\TEDResources\node.js\nodetest1  \npm-debug.log  npm ERR! not ok code 0  

//npm-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@1.4.28  3 info using node@v0.10.32  4 verbose node symlink C:\Program Files\nodejs\\node.exe  5 verbose run-script [ 'prestart', 'start', 'poststart' ]  6 info prestart nodetest1@0.0.0  7 info start nodetest1@0.0.0  8 verbose unsafe-perm in lifecycle true  9 info nodetest1@0.0.0 Failed to exec start script  10 error nodetest1@0.0.0 start: `node ./bin/www`  10 error Exit status 8  11 error Failed at the nodetest1@0.0.0 start script.  11 error This is most likely a problem with the nodetest1 package,  11 error not with npm itself.  11 error Tell the author that this fails on your system:  11 error     node ./bin/www  11 error You can get their info via:  11 error     npm owner ls nodetest1  11 error There is likely additional logging output above.  12 error System Windows_NT 6.1.7601  13 error command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"  14 error cwd C:\Users\kellington\Documents\GitHub\TEDResources\node.js\nodetest1  15 error node -v v0.10.32  16 error npm -v 1.4.28  17 error code ELIFECYCLE  18 verbose exit [ 1, true ]  

//package.json

{    "name": "nodetest1",    "version": "0.0.0",    "private": true,    "scripts": {      "start": "node ./bin/www"    },    "dependencies": {      "express": "~4.9.0",      "body-parser": "~1.8.1",      "cookie-parser": "~1.3.3",      "morgan": "~1.3.0",      "serve-favicon": "~2.1.3",      "debug": "~2.0.0",      "jade": "~1.6.0",       "mongodb": "*",      "monk": "*"    }  }  

//app.js

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');    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(express.static(path.join(__dirname, 'public'))); app.use('/', routes); app.use('/users', users); // 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; Microsoft Windows [Version 6.1.7601]

Copyright (c) 2009 Microsoft Corporation. All rights reserved.

//dir result

> nodetest1@0.0.0 start C:\Users\username\Documents\GitHub\TEDResources\node.j  s\nodetest1  > dir     Volume in drive C is OS   Volume Serial Number is F87D-8771     Directory of C:\Users\username\Desktop    10/23/2014  11:13 AM              .  10/23/2014  11:13 AM              ..  10/13/2014  09:14 AM           146,016 7f6bd778-1c67-43fd-9865-372789ed7592_Loca  lIISWebsite.zip  10/07/2014  03:39 PM             1,086 Blue Eye Macro.lnk  08/28/2014  12:07 PM             1,197 DesignEphiphany.txt  10/22/2014  08:03 AM             2,163 Git Shell.lnk  04/17/2014  10:51 AM               308 GitHub.appref-ms  10/21/2014  10:54 AM              LocalIISWebsite  10/23/2014  11:11 AM              node.js  10/14/2014  10:07 AM              TextDocs                   7 File(s)      1,704,717 bytes                 8 Dir(s)  352,881,205,248 bytes free  

Answer by subpath42 for npm start looking for /bin/www in the wrong directory, how to update


Had a windows registry entry for "autorun" - "problem directory" setup for a default start directory that was overriding commands. Removed it from registry and fixed the issue. Thank you to laggingreflex for helping me debug this.

Answer by farhangdon for npm start looking for /bin/www in the wrong directory, how to update


I had this same error when I was creating my First Node Project using express. But when i tried running it using

node ./bin/www              // it will work  

instead of

npm start  

The server started at port 3000. you can check your app on localhost:3000 .
May be it can help some One else :)

Answer by lacostenycoder for npm start looking for /bin/www in the wrong directory, how to update


I had the same problem following this tutorial, only after killing server for the first time as per instructions. I tried a bunch of things, including those listed above and on several other threads. However simply removing or commenting out the following in app.js did the trick :

//var mongo = require('mogodb')  

Answer by Dave Munger for npm start looking for /bin/www in the wrong directory, how to update


Fwiw, I had the same error and it turned out to be that something was already running on port 3000. I mention this because the debug log mentioned nothing about this, just a similar error to yours. So maybe this will help somebody who comes across this post and happens to have the problem I did.

Answer by Fernando D. Bozzo for npm start looking for /bin/www in the wrong directory, how to update


This happened to me today, same error looking to the same tutorial, but with this setup:

  • Ubuntu 14.04
  • npm v5.11.1
  • node v3.9.2

First intent was searching on the web and found this page, and can't solve the problem with what was said, but found a clue to follow.

Second intent was to list apps using the same port (3000) with this:

sudo netstat -ep | grep 3000  

But nothing.

Third intent was to change the port number used un "nodetest1/bin/www" file from 3000 to 3001, and that did the trick.

var port = normalizePort(process.env.PORT || '3001');  

From there, I now can browse http://localhost:3001 and keep following the tutorial.

Edit: I've found that I've incorrectly used netstat, and this showed whats program is using the port 3000:

sudo netstat -epa | grep 3000  

ntop is using it:

tcp        0      0 *:3000                  *:*                     ESCUCHAR    root       15508       2289/ntop  

So in my case changing the nodetest1 port on www file was the only viable solution.

Hope this help others.


Fatal error: Call to a member function getElementsByTagName() on a non-object in D:\XAMPP INSTALLASTION\xampp\htdocs\endunpratama9i\www-stackoverflow-info-proses.php on line 72

Related Posts:

0 comments:

Post a Comment

Popular Posts

Fun Page

Powered by Blogger.