Pug 预处理器和缩进问题

Problem with Pug pre-processor and indentation

我在监视文件时遇到问题

以及出现的错误=>

Error: .//index.pug:2:1
    1| doctype html
  > 2|    html
-------^
    3|
    4|      head
    5|

unexpected token "indent"
    at makeError (C:\Users\amb\AppData\Roaming\npm\node_modules\pug-cli\node_modules\pug-error\index.js:32:13)
    at Parser.error (C:\Users\amb\AppData\Roaming\npm\node_modules\pug-cli\node_modules\pug-parser\index.js:53:15)
    at Parser.parseExpr (C:\Users\amb\AppData\Roaming\npm\node_modules\pug-cli\node_modules\pug-parser\index.js:264:14)
    at Parser.parse (C:\Users\amb\AppData\Roaming\npm\node_modules\pug-cli\node_modules\pug-parser\index.js:112:25)
    at parse (C:\Users\amb\AppData\Roaming\npm\node_modules\pug-cli\node_modules\pug-parser\index.js:12:20)
    at Object.parse (C:\Users\amb\AppData\Roaming\npm\node_modules\pug-cli\node_modules\pug\lib\index.js:126:22)
    at Function.loadString [as string] (C:\Users\amb\AppData\Roaming\npm\node_modules\pug-cli\node_modules\pug-load\index.js:45:21)
    at compileBody (C:\Users\amb\AppData\Roaming\npm\node_modules\pug-cli\node_modules\pug\lib\index.js:86:18)
    at Object.exports.compile (C:\Users\amb\AppData\Roaming\npm\node_modules\pug-cli\node_modules\pug\lib\index.js:242:16)
    at handleTemplateCache (C:\Users\amb\AppData\Roaming\npm\node_modules\pug-cli\node_modules\pug\lib\index.js:215:25)

有什么帮助吗?

可能您在第 1 行末尾有一个制表符,或者处理器期望在第 2 行开头有一个制表符,而您有空格(反之亦然)

doctype html

html
  head
    meta
    title

  body
    h1 Tag

//- Remember
  //- Use 2 Spaces Tab
  //- Be sure to check any tabs or spaces at the end of line

//- doctype html and html - without any tabs

//- head and body - with 1 tab or 2 spaces

//- meta, title and h1- with 2 tab or 4 spaces