Module build failed: Error: No parser and no file path given, couldn't infer a parser.
at normalize (/home/nayan/dd_pwa/node_modules/prettier/index.js:7051:13)
at formatWithCursor (/home/nayan/dd_pwa/node_modules/prettier/index.js:10370:12)
at /home/nayan/dd_pwa/node_modules/prettier/index.js:31115:15
at Object.format (/home/nayan/dd_pwa/node_modules/prettier/index.js:31134:12)
at Object.module.exports (/home/nayan/dd_pwa/node_modules/vue-loader/lib/template-compiler/index.js:80:23)
@ ./layouts/error.vue 7:0-368
@ ./.nuxt/index.js
@ ./.nuxt/client.js
@ multi webpack-hot-middleware/client?name=client&reload=true&timeout=30000&path=/__webpack_hmr ./.nuxt/client.js
我在Nuxtjs上有same issue。任何面临同样问题的人救命?!! 版: " nuxt":" ^ 1.0.0", "更漂亮":" ^ 1.12.1"
尝试了降级和升级更漂亮版本的所有选项。
答案 0 :(得分:25)
更新: 我在下面的评论中提到了这一点,但出于某种原因,人们仍然提到同样的事情。
甚至懒得降级。
这是一个小问题。
我给出了解释并what worked for me here:
简而言之:
去:
node_modules\vue-loader\lib\template-compiler
...打开index.js
并查找
// prettify render fn
if (!isProduction) {
code = prettier.format(code, { semi: false})
}
并将行更改为:
// prettify render fn
if (!isProduction) {
code = prettier.format(code, { semi: false, parser: 'babylon' })
}
多数民众赞成!
答案 1 :(得分:19)
将import {GOOD_TOKEN, INVALID_TOKEN} from "../constants";
function immediateReturnTrue(){
return true;
}
function immediateReturnFalse(){
return false;
}
export const VerifyTokenReducer = (state = {}, action) => {
switch (action.type) {
case GOOD_TOKEN:
return {
isAuthenticated: true,
wrapper: immediateReturnTrue
};
case INVALID_TOKEN:
return {
isAuthenticated: false,
wrapper: immediateReturnFalse
};
default:
return state;
}
};
软件包降级到版本1.12.1并坚持使用它:
prettier
答案 2 :(得分:-1)
这是一个现在修复它的sed one-liner:
sed -i 's/semi: false/semi: false, parser: \"babylon\"/g' node_modules/vue-loader/lib/template-compiler/index.js
对于mac:
sed -i '' 's/semi: false/semi: false, parser: \"babylon\"/g' node_modules/vue-loader/lib/template-compiler/index.js
作为npm脚本:
"scripts": {
"postinstall": "sed -i 's/semi: false/semi: false, parser: \"babylon\"/g' node_modules/vue-loader/lib/template-compiler/index.js"
}