Running into “couldn't infer parser” error using vue-cli

后端 未结 5 1812
天命终不由人
天命终不由人 2020-12-31 14:59

I\'m getting an error repeatedly when trying to build a new webpack project using vue-cli. I\'m following along with the docs on the latest build (3.0.0-beta.11

5条回答
  •  悲哀的现实
    2020-12-31 15:19

    Right now, I tried all the options..downloading and updgrading prettier...but none workied. Until I studied what happened carefully. Apparently, the prettier team removed the default parser which was babylon and in so doing...broke the internet.

    Just kidding.

    Issue repo

    The simplest solution, according to them would be to simply add the parser back. This has been picked up by the Vue team and its expected to be shipped with the latest fix release. If you are using Vue Loader/Yarn, dont even bother to try all the suggestions...I tried them all. What fixed it for me was...go to node_modules\vue-loader\lib\template-compiler ...open index.js and look for

    // prettify render fn if (!isProduction) { code = prettier.format(code, { semi: false}) }

    and change the lines to:

    // prettify render fn
    if (!isProduction) {
      code = prettier.format(code, { semi: false, parser: 'babylon' })
    }
    

    Thats it! Then once the issue got fixed, everything will just be rolled back and you will still be fine.

    Try this...it will save you countless minutes of searches....

提交回复
热议问题