[英]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. 我正在尝试安装
app.js
来创建HTTP服务器,但是该版本来自旧的Express version (3.x)
,因此他安装了不推荐使用的版本,该版本使用的功能不再可用,例如app.configure()
甚至其他代码,但我不知道如何将此代码转换为新版本。
My code : 我的代码:
app.js 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 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|
500错误:C:\\ Users \\ Leandro Mont \\ Desktop \\ Lucas \\ Node \\ Professional Node \\ my_app / views / layout.jade:1> 1 | !!!
!!! 2|
2 | html 3|
html 3 | head 4|
头4 | title= title
!!!
标题=标题
!!!
is deprecated, you must now usedoctype
已弃用,您现在必须使用
doctype
What are the modifications that I need to do, to make it work ? 为了使它起作用,我需要做哪些修改?
Instead of using !!!
而不是使用
!!!
(which is deprecated, as the error says), use doctype
: (如错误所示,已弃用),请使用
doctype
:
doctype html
html
head
title= title
link(rel='stylesheet', href='/stylesheets/style.css')
body!= body
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.