遇到“无法推断解析器"使用 vue-cli 时出错 [英] Running into "couldn't infer parser" error using vue-cli
问题描述
在尝试使用 vue-cli
构建新的 webpack 项目时,我反复收到错误消息.我正在关注最新版本 (3.0.0-beta.11) 的文档,也尝试过早期版本,但不是测试版.
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), also tried with an earlier version, which wasn't beta.
当我运行 yarn serve
时,它尝试启动开发服务器并构建项目,但在此处失败:
When I run yarn serve
it attempts to start the dev server and build the project but fails here:
error in ./src/App.vue?vue&type=template&id=7ba5bd90
Module build failed: Error: No parser and no file path given, couldn't infer a parser.
at normalize (/Users/cory/Code/chickadee/my-project/node_modules/prettier/index.js:7051:13)
at formatWithCursor (/Users/cory/Code/chickadee/my-project/node_modules/prettier/index.js:10370:12)
at /Users/cory/Code/chickadee/my-project/node_modules/prettier/index.js:31115:15
at Object.format (/Users/cory/Code/chickadee/my-project/node_modules/prettier/index.js:31134:12)
at actuallyCompile (/Users/cory/Code/chickadee/my-project/node_modules/@vue/component-compiler-utils/dist/compileTemplate.js:93:29)
at compileTemplate (/Users/cory/Code/chickadee/my-project/node_modules/@vue/component-compiler-utils/dist/compileTemplate.js:26:16)
at Object.module.exports (/Users/cory/Code/chickadee/my-project/node_modules/vue-loader/lib/loaders/templateLoader.js:42:20)
@ ./src/App.vue?vue&type=template&id=7ba5bd90 1:0-194 1:0-194
@ ./src/App.vue
@ ./src/main.js
@ multi (webpack)-dev-server/client/index.js (webpack)/hot/dev-server.js ./src/main.js
关于我的设置
- Mac 操作系统
- 我正在运行 node v8.5.0
- 使用
yarn
安装包
- 不同版本的
vue-cli
生成新项目.项目生成并安装模块. - 尝试删除
prettier
模块,但错误似乎仍然出现. - 尝试重新安装所有模块.
- Different versions of
vue-cli
to generate a new project. The projects generate and install modules. - Tried removing the
prettier
module, but the error still seems to come up. - Tried reinstalling all modules.
我还能尝试什么来克服这个错误?
What else might I try to get past this error?
推荐答案
从项目中移除当前的 node_modules
文件夹,添加 "prettier": "^1.12.1"
到 package.json
并运行 npm install
解决了这个问题.
Removing the current node_modules
folder from the project, adding "prettier": "^1.12.1"
to package.json
and running npm install
solved the issue.
另一种选择是运行 npm install prettier@1.12.1
而无需删除 node_modules
之前的文件夹
Another option is to run npm install prettier@1.12.1
without removeing the node_modules
folder before
更新:
对于某些用户来说,1.12.1 版不起作用
For some users, verion 1.12.1 did not work
@Kivin 提出了另一种解决方案,可以在这里找到:vue webpack 模板缺少解析器
@Kivin proposed another solution that can be found here: vue webpack template missing parser
这篇关于遇到“无法推断解析器"使用 vue-cli 时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!