如何解决哈巴狗的[意外令牌“缩进”]错误?

问题描述 投票:0回答:1
Error: /home/user/Desktop/app/backend/views/register.pug:2:1
    1|  doctype html
  > 2|  html
-------^
    3|    head
    4|      title = title
    5|    body

unexpected token "indent"
    at makeError (/home/user/Desktop/app/backend/node_modules/pug-error/index.js:32:13)
    at Parser.error (/home/user/Desktop/app/backend/node_modules/pug-parser/index.js:53:15)
    at Parser.parseExpr (/home/user/Desktop/app/backend/node_modules/pug-parser/index.js:264:14)
    at Parser.parse (/home/user/Desktop/app/backend/node_modules/pug-parser/index.js:112:25)
    at parse (/home/user/Desktop/app/backend/node_modules/pug-parser/index.js:12:20)
    at Object.parse (/home/user/Desktop/app/backend/node_modules/pug/lib/index.js:125:22)
    at Function.loadString [as string] (/home/user/Desktop/app/backend/node_modules/pug-load/index.js:45:21)
    at compileBody (/home/user/Desktop/app/backend/node_modules/pug/lib/index.js:86:18)
    at Object.exports.compile (/home/user/Desktop/app/backend/node_modules/pug/lib/index.js:242:16)
    at handleTemplateCache (/home/user/Desktop/app/backend/node_modules/pug/lib/index.js:215:25)
    at Object.exports.renderFile (/home/user/Desktop/app/backend/node_modules/pug/lib/index.js:427:10)
    at Object.exports.renderFile (/home/shivtaj/Desktop/app/backend/node_modules/pug/lib/index.js:417:21)
    at View.exports.__express [as engine] (/home/user/Desktop/app/backend/node_modules/pug/lib/index.js:464:11)
    at View.render (/home/user/Desktop/app/backend/node_modules/express/lib/view.js:135:8)
    at tryRender (/home/user/Desktop/app/backend/node_modules/express/lib/application.js:640:10)
    at Function.render (/home/user/Desktop/app/backend/node_modules/express/lib/application.js:592:3)
pug
1个回答
0
投票

帕格对压痕非常敏感。上面的错误消息表明你在html标记之前有一个空格字符,它不喜欢它。

doctype htmlhtml线移到最左边,所以前面没有空格。然后,确保其他行正确缩进(两个空格进行缩进),否则您将看到剩余行上的缩进错误。

© www.soinside.com 2019 - 2024. All rights reserved.