Node . /bin/www and nothing happens

Asked

Viewed 152 times

-1

I’m running a Rawler that I found on github, but it has no documentation, I created an Issue but I got no answer, and I’m very amateur, so maybe my doubt seems noobesca, but I would like help.

Rodo 'Node bin/www', because Node app.js was returning a sinister error. Now with bin/www simply it goes to the next line and nothing happens.

I imagine it might be progress, but Crawler still doesn’t work. I don’t know how to proceed. If you can help me, I am very grateful.

App code.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', 'ejs');

// uncomment after placing your favicon in /public
//app.use(favicon(path.join(__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;

I found out about Node bin/www in package.json

    "start": "node ./bin/www"
  },

and the content of www is?

    #!/usr/bin/env node

/**
 * Module dependencies.
 */

var app = require('../app');
var debug = require('debug')('tripadvisor: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);
}
  • Rafael speaks I’m not an expert either, but wouldn’t NODE START be the command? I don’t know if this will solve your question because I’m on a tight schedule right now, but then I take a closer look and try to help you.

  • Node start is also not mano, http://imgur.com/a/uiLbV

  • As soon as I can better validate the code you passed and the options

  • @Thiagosantos I still can’t solve the problem.

1 answer

-3

The executable Node command only executes ". js" files, www does not have this extension, so try ". /bin/www". See if you are allowed to run the "chmod +x . /bin/www file"

  • thanks for the return, but I use Windows (yes, I know, I should use linux). And yes, I tried this 'Node'. /bin/www' also tried only app.js, unsuccessfully

Browser other questions tagged

You are not signed in. Login or sign up in order to post.