Error on brand new express project doctype 5` is deprecated, you must now use `doctype html`

StackOverflow https://stackoverflow.com/questions/20909817

  •  24-09-2022
  •  | 
  •  

Вопрос

Created a brand new express.js project by running the following commands on a windows command prompt

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

I then open a browser window to http://localhost:3000/ and get the following error

    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)
Это было полезно?

Решение

To fix your current project and any projects you build with the current version of Express, go to your layout.jade file and change the first line to: doctype html (the second line should read: html)

The issue with is known and has been resolved so it will not be an issue in a future version of Express. https://github.com/visionmedia/express/pull/1875

Другие советы

Use :

doctype html
html(lang="en")

change "doctype 5" to "doctype html" on line 1 of views/layout.jade for your brand new project.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top