1. 程式人生 > >vue專案建立時報錯:Module build failed: Error: No parser and no file path given, couldn't infer a parser.

vue專案建立時報錯:Module build failed: Error: No parser and no file path given, couldn't infer a parser.

在建立一個vue專案啟動時報錯,報錯的內容為:
error in ./src/App.vue

Module build failed: Error: No parser and no file path given, couldn’t infer a p
arser.
at UndefinedParserError.Wrapper (D:\dyyc\bookstore\[email protected]
[email protected]\index.js:1948:14)
at new UndefinedParserError (D:\dyyc\bookstore\

[email protected]
@prettier\index.js:2055:83)
at normalize (D:\dyyc\bookstore\[email protected]@prettier\index
.js:7051:13)
at formatWithCursor (D:\dyyc\bookstore\[email protected]@prettie
r\index.js:10370:12)
at D:\dyyc\bookstore\[email protected]@prettier\index.js:31115:1
5
at Object.format (D:\dyyc\bookstore\
[email protected]
@prettier\i
ndex.js:31134:12)
at Object.module.exports (D:\dyyc\bookstore\[email protected]@
vue-loader\lib\template-compiler\index.js:80:23)

@ ./src/App.vue 11:0-392
@ ./src/main.js
@ multi ./node_modules/[email protected]@webpack-dev-server/client?htt
p://localhost:8082 webpack/hot/dev-server ./src/main.js

是prettier模組導致的報錯,查了下發現In prettier 1.13.0, default parser was removed with a minor version(used to be babylon), this breaks the formatter here.意思是在prettier的 1.13.0版本,預設的一個解析器被移除了導致專案建立失敗

解決辦法把node_modules裡的prettier刪掉,重現下個之前的版本 npm install [email protected]~1.12.0再執行就可以了