Solution for node app. js not working

Source: Internet
Author: User

In Express 3.0, you normally wocould use app. configure () (or app. use () to set up the required middleware you need. those middleware you specified are bundled together with Express 3.0.

E.g.

var express = require('express');var routes = require('./routes');var user = require('./routes/user');var http = require('http');var path = require('path');var app = express();// all environmentsapp.set('port', process.env.PORT || 3000);app.set('views', path.join(__dirname, 'views'));app.set('view engine', 'jade');app.use(express.favicon());app.use(express.logger('dev'));app.use(express.compress());app.use(express.json());app.use(express.urlencoded());app.use(express.methodOverride());

In Express 4.0 however, all middleware have been removed so that they can be maintained and update independently from the core Express (could t the static middleware ), thus they need to be called separately (what you see in app. js ).

Thebin\Directory serve as a location where you can define your various startup scripts,wwwIs an example on how it showould looks like, ultimately you cowould have startup script liketest,stopOrrestartEtc. Having this structure allows you to have different deployments without touching the app. js.

So the correct start method isnpm start

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.