Vue-cli_报错No parser and no file path given, couldn't infer a parser

刚才在安装完Vue-cli后, 运行npm run dev时报错

错误信息如下:

Module build failed: Error: No parser and no file path given, couldn't infer a parser.


详细错误信息如下:

mac:vue_cli_01 beyond$ pwd
/Users/beyond/sg_webpack/vue_cli_01
mac:vue_cli_01 beyond$ ls
README.md		index.html		package.json
build			node_modules		src
config			package-lock.json	static
mac:vue_cli_01 beyond$ npm run dev

> [email protected] dev /Users/beyond/sg_webpack/vue_cli_01
> webpack-dev-server --inline --progress --config build/webpack.dev.conf.js

 94% asset optimization                                                              

 ERROR  Failed to compile with 2 errors                                                                   14:37:52

 error  in ./src/App.vue

Module build failed: Error: No parser and no file path given, couldn't infer a parser.
    at normalize (/Users/beyond/sg_webpack/vue_cli_01/node_modules/prettier/index.js:7051:13)
    at formatWithCursor (/Users/beyond/sg_webpack/vue_cli_01/node_modules/prettier/index.js:10370:12)
    at /Users/beyond/sg_webpack/vue_cli_01/node_modules/prettier/index.js:31115:15
    at Object.format (/Users/beyond/sg_webpack/vue_cli_01/node_modules/prettier/index.js:31134:12)
    at Object.module.exports (/Users/beyond/sg_webpack/vue_cli_01/node_modules/vue-loader/lib/template-compiler/index.js:80:23)

 @ ./src/App.vue 11:0-354
 @ ./src/main.js
 @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.js

 error  in ./src/components/HelloWorld.vue

Module build failed: Error: No parser and no file path given, couldn't infer a parser.
    at normalize (/Users/beyond/sg_webpack/vue_cli_01/node_modules/prettier/index.js:7051:13)
    at formatWithCursor (/Users/beyond/sg_webpack/vue_cli_01/node_modules/prettier/index.js:10370:12)
    at /Users/beyond/sg_webpack/vue_cli_01/node_modules/prettier/index.js:31115:15
    at Object.format (/Users/beyond/sg_webpack/vue_cli_01/node_modules/prettier/index.js:31134:12)
    at Object.module.exports (/Users/beyond/sg_webpack/vue_cli_01/node_modules/vue-loader/lib/template-compiler/index.js:80:23)

 @ ./src/components/HelloWorld.vue 11:0-366
 @ ./src/router/index.js
 @ ./src/main.js
 @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.js


github上实时讨论地址如下:

https://github.com/vuejs/component-compiler-utils/issues/14




原因是: prettier 新版v1.12.1中, 有一行代码,如下所示

Vue-cli_报错No parser and no file path given, couldn't infer a parser_第1张图片





解决办法:

1. npm i prettier@~1.12.0


2. npm run dev


Vue-cli_报错No parser and no file path given, couldn't infer a parser_第2张图片



Vue-cli_报错No parser and no file path given, couldn't infer a parser_第3张图片
























你可能感兴趣的:(Vue)