web-dev-qa-db-ja.com

新しいExpressプロジェクトのエラーdoctype 5`は廃止されました。`doctypehtml`を使用する必要があります

Windowsコマンドプロンプトで次のコマンドを実行して、まったく新しいexpress.jsプロジェクトを作成しました

npm install express -g 
express newproject
cd newproject
npm install
node app

次に、ブラウザウィンドウを開いてhttp://localhost:3000/および次のエラーを取得します

    500 Error: c:\projects\newproject\views\index.jade:5<br/> 3| block content <br/> 4| h1= title <br/> > 5| p Welcome to #{title}<br/><br/>`doctype 5` is deprecated, you must now use `doctype html`
3| block content 
4| h1= title 
> 5| p Welcome to #{title}

`doctype 5` is deprecated, you must now use `doctype html`
at Object.Compiler.setDoctype (c:\projects\newproject\node_modules\jade\lib\compiler.js:68:13)
at Object.Compiler.visitDoctype (c:\projects\newproject\node_modules\jade\lib\compiler.js:312:12)
at Object.Compiler.visitNode (c:\projects\newproject\node_modules\jade\lib\compiler.js:210:37)
at Object.Compiler.visit (c:\projects\newproject\node_modules\jade\lib\compiler.js:197:10)
at Object.Compiler.visitBlock (c:\projects\newproject\node_modules\jade\lib\compiler.js:278:12)
at Object.Compiler.visitNode (c:\projects\newproject\node_modules\jade\lib\compiler.js:210:37)
at Object.Compiler.visit (c:\projects\newproject\node_modules\jade\lib\compiler.js:197:10)
at Object.Compiler.compile (c:\projects\newproject\node_modules\jade\lib\compiler.js:52:10)
at parse (c:\projects\newproject\node_modules\jade\lib\jade.js:96:23)
at Object.exports.compile (c:\projects\newproject\node_modules\jade\lib\jade.js:152:9)
26
Bryan Focht

現在のプロジェクトと、現在のバージョンのExpressでビルドしたプロジェクトを修正するには、layout.jadeファイルに移動して、最初の行をdoctype htmlに変更します(2行目はhtmlになっているはずです)。

の問題は既知であり、解決されているため、Expressの将来のバージョンでは問題にはなりません。 https://github.com/visionmedia/express/pull/1875

49
canadaCoder

使用する :

doctype html
html(lang = "en")

15
Girish Kumar

新しいプロジェクトのviews/layout.jadeの1行目で「doctype 5」を「doctype html」に変更します。

1
Rob