Monday, 12 June 2017

Installing app.js error Node.js

I am trying to install app.js to create an HTTP server, but this version is from the old Express version (3.x) and so he install a version deprecated, that uses commands that are no longer functional, like app.configure() and even others, but I don't know how to make work this code to the new version.

My code :

app.js

/**
 * Module dependencies.
 */

var express = require('express')
  , routes = require('./routes');

var app = module.exports = express.createServer();

// Configuration

app.configure(function(){
  app.set('views', __dirname + '/views');
  app.set('view engine', 'jade');
  app.use(express.bodyParser());
  app.use(express.methodOverride());
  app.use(app.router);
  app.use(express.static(__dirname + '/public'));
});

app.configure('development', function(){
  app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});

app.configure('production', function(){
  app.use(express.errorHandler());
});

// Routes

app.get('/', routes.index);

app.listen(3000, function(){
  console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env);
});

layout.jade

!!!
html
  head
    title= title
    link(rel='stylesheet', href='/stylesheets/style.css')
  body!= body

He points out some error like :

500 Error: C:\Users\Leandro Mont\Desktop\Lucas\Node\Professional Node\my_app/views/layout.jade:1 > 1| !!! 2| html 3| head 4| title= title !!! is deprecated, you must now use doctype

What are the modifications that I need to do, to make it work ?



via Monteiro

No comments:

Post a Comment