简体   繁体   English

缩进不一致:如何解决?

[英]Inconsistent Indentation: How do I fix it?

I am attemping to make a game in JavaScript, but when I try to localhost it in Node.js, i get an error like this:我正在尝试用 JavaScript 制作游戏,但是当我尝试在 Node.js 中本地化它时,我收到如下错误:

Inconsistent indentation. Expecting either 6 or 8 spaces/tabs.

    at makeError (C:\Users\Joshua Chuah\node\node_modules\pug-error\index.js:32:13)
    at Lexer.error (C:\Users\Joshua Chuah\node\node_modules\pug-lexer\index.js:59:15)
    at Lexer.indent (C:\Users\Joshua Chuah\node\node_modules\pug-lexer\index.js:1337:18)
    at Lexer.callLexerFunction (C:\Users\Joshua Chuah\node\node_modules\pug-lexer\index.js:1456:23)
    at Lexer.advance (C:\Users\Joshua Chuah\node\node_modules\pug-lexer\index.js:1495:15)
    at Lexer.callLexerFunction (C:\Users\Joshua Chuah\node\node_modules\pug-lexer\index.js:1456:23)
    at Lexer.getTokens (C:\Users\Joshua Chuah\node\node_modules\pug-lexer\index.js:1512:12)
    at lex (C:\Users\Joshua Chuah\node\node_modules\pug-lexer\index.js:12:42)
    at Object.lex (C:\Users\Joshua Chuah\node\node_modules\pug\lib\index.js:99:27)
    at Function.loadString [as string] (C:\Users\Joshua Chuah\node\node_modules\pug-load\index.js:44:24)

Hows does one fix my issues?如何解决我的问题? (Even after trying to convert all of my tabs to spaces in an attempt to fix my issue I have come to no avail, before suggesting that) (即使在尝试将我的所有制表符转换为空格以尝试解决我的问题之后,在建议之前我也无济于事)

As the error states, make sure to have consistent indentation. 由于错误状态,请确保具有一致的缩进。 Just having spaces or tabs isn't enough. 仅使用空格或制表符是不够的。 You'll need the same amount per line, depending on what indentation you are currently on. 每行需要相同的金额,具体取决于您当前使用的缩进方式。

You may also use one of the online beautifier tools, such as this one: https://pughtml.com/ 您也可以使用一种在线美化工具,例如以下一种: https : //pughtml.com/

This error occurs when you by mistake entered unwanted space in your program while using any templating engine.当您在使用任何模板引擎时错误地在程序中输入了不需要的空间时,就会发生此错误。 In my case I am using the pug and when same errors shows up I simply remove the extra space entered in my program...就我而言,我正在使用哈巴狗,当出现相同的错误时,我只需删除程序中输入的额外空间......

thanks below answer from @deadshot helped me This error occurs when you by mistake entered unwanted space in your program while using any templating engine.感谢@deadshot的以下回答帮助了我当您在使用任何模板引擎时错误地在程序中输入了不需要的空间时,就会发生此错误。 In my case I am using the pug and when same errors shows up I simply remove the extra space entered in my program...就我而言,我正在使用哈巴狗,当出现相同的错误时,我只需删除程序中输入的额外空间......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM