Closed pwang2 closed 6 years ago
Damn. Just decided to try the vue-cli out and ended up with the no parser error on a newly init'ed project. I was at a complete loss, but managed to find my way to the prettier breaking change. Good job finding a solution this quick and thanks, implemented this locally. 👍
in ./src/App.vue
Module build failed: Error: No parser and no file path given, couldn't infer a parser. at normalize (/Users/lanc/Desktop/runbuild/node_modules/_prettier@1.13.0@prettier/index.js:7051:13) at formatWithCursor (/Users/lanc/Desktop/runbuild/node_modules/_prettier@1.13.0@prettier/index.js:10370:12) at /Users/lanc/Desktop/runbuild/node_modules/_prettier@1.13.0@prettier/index.js:31115:15 at Object.format (/Users/lanc/Desktop/runbuild/node_modules/_prettier@1.13.0@prettier/index.js:31134:12) at Object.module.exports (/Users/lanc/Desktop/runbuild/node_modules/_vue-loader@13.7.1@vue-loader/lib/template-compiler/index.js:80:23)
@ ./src/App.vue 11:0-392 @ ./src/main.js @ multi ./node_modules/_webpack-dev-server@2.11.2@webpack-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.js
How to solve this?
as a workaround, in your package.json, force prettier to be 1.12 with
npm install prettier@~1.12.1 .
UPDATE: NO need to do downgrade prettier version now, this was working as workaround before release of @vue/component-compiler-utils 1.3.1
If you have applied downgrade above, remove it from pacakge.json then run
npm update --depth=9999 @vue/component-compiler-utils
if havn't just run
npm update --depth=9999 @vue/component-compiler-utils
@pwang2 not work, still get 1.13.0
npm view prettier version
@lovemyliwu if you are using customized tools or npm link, it might be tricky and requires you to target the package tree correctly.
You might also need to regenerate you pacakge-lock.json or yarn.lock file.
Merged.
Thanks @yyx990803 ! We could expect a new version of @vue/component-compiler-utils
soon.
Released in 1.3.1
remove node_modules
and reinstall everything.
还是不行啊,尤大婶
rm -rf package-lock.json node_modules
npm install
rm -rf node_modules
npm install
npm install prettier@~1.12.1
rm -rf node_modules npm install npm install prettier@~1.12.1
亲测有效,谢谢~
nuxtjs
still doesn't work.... The same error with prettier
you can try cd node_modules/ rm -rf _prettier@1.13.0@prettier cnpm install prettier@~1.12.1
(if your node_modules/ have _prettier@1.13.0@prettier )
@lanxin1234 no need install prettier-1.12.x. use npm replace cnpm, or wait taobao update component-compiler-utils-1.3.0 to 1.3.1
此问题尤大已经解决,无需降级prettier。删掉node_modules,yarn.lock, package-lock.json 等文件,再拉取一次package就行。淘宝镜像同步稍晚了一会,现在也已经ok了。
Yarn and npm registries are still pointing to 1.13.0, not 1.13.1.
@lanxin1234 it work with this manual install.
@transtone only nuxt@1.4.0
has this error. It use vue-loader@13.7.0
. But nuxt@1.4.0
is the newest stable version....
@lanxin1234 是的,需要删掉,我是这样写的,成功了,感谢
rm -rf node_modules
cnpm cache verify
cnpm i
rm -rf node_modules/_prettier@1.13.0@prettier
cnpm install --save-dev prettier@1.12.0
上面的方法都试了,还是报错
rm -rf node_modules npm install npm install prettier@~1.12.1 我的成功了
楼上我也是不行~
今天打算把线上的分支拉多一个到本地做迭代. 然后装完package就报错了. 旧的包是可以的.
我还以为是跟同事更新代码搞错了 - -
分享下,此官方修复只针对 vue-loader 15.x 版本,如果你项目引用的是 13.x/14.x等版本,与此修复无关,需升级 vue-loader 至 15.x版,
升级后需要注意不兼容更新: https://vue-loader.vuejs.org/migrating.html#notable-breaking-changes
`// webpack.config.js const VueLoaderPlugin = require('vue-loader/lib/plugin')
module.exports = { // ... plugins: [ new VueLoaderPlugin() ] }`
rm -rf node_modules
npm install
rm -rf node_modules/_prettier@1.13.0@prettier
npm install prettier@~1.12.1
试试这样
window 10 下
cnpm i
rm node_modules/_prettier@1.13.0@prettier
// 输入 a 回车
cnpm i prettier@~1.12.1 -D
删 node_modules npm install npm run dev 可以了
我也在报错
怎么做的?
npm install --save-dev prettier@1.12.1
nuxt项目有大佬搞定了么,
nuxt@1.4.0
npm install --save-dev prettier@1.12.1
也不行
npm install prettier@~1.12.1 这个是可以的
@chengzhuotc 升级完vue -loader 后 没有其他的报错吗?有解决吗
目前没有其他保错,已解决,谢谢😘
liuhuidi428 邮箱:liuhuidi428@163.com |
---|
签名由 网易邮箱大师 定制
在2018年05月28日 15:32,Ya jie 写道:
@chengzhuotc 升级完vue -loader 后 没有其他的报错吗?有解决吗
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
为什么我npm install --save-dev prettier@1.12.1也会报错
@huyajie 这样做就好了
还是不行
不知道是不是和node环境有关,我用的是10点几版本的,然后照着上面试了很多次不行,然后我吧vue-loader升级最新版本, 在改下配置,然后照着上面降级就可以了
用的是 vue 2.3.0 和 vue -loader 14.2.1, 删了node_modules后重新npm install后还是报错;但手动install 1.12.1 版本的 prettier 就可以了
作为一个node小白,这问题我也弄了一个多小时,最先还以为我哪里代码写错了,查了一通才查到这里,谷歌真牛掰,这个issue10几个小时前提的,谷歌就能搜出来了。
顺便鄙视一下百度
难道这问题作者没关注么?
用 vue init 生成新项目,竟然报错, 好神奇啊。。。
感觉没权威性啊,老报错。。。
@tianxiaofeng 报错啊
@yangguang111lll 我也报错, 老项目可以的。 奇怪。
nuxt项目解决了 在推送服务器上,装完依赖过后,手动单独安装一次prettier就好了
@yangguang111lll window 10 下
cnpm i rm node_modules/_prettier@1.13.0@prettier // 输入 a 回车 cnpm i prettier@~1.12.1 -D
试了4个小时,,试光了所有方法。。绝望
心累
I can't me too
🐣👏🏻👑给你,心累拿走!谢谢!
liuhuidi428 邮箱:liuhuidi428@163.com |
---|
签名由 网易邮箱大师 定制
在2018年05月28日 16:16,hlg-facai 写道:
心累
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
In prettier 1.13.0, default parser was removed with a minor version(used to be babylon), this breaks the formatter here.
https://github.com/vuejs/component-compiler-utils/blob/8a8a95c84dc2f3f14625e31805f975d11a898990/lib/compileTemplate.ts#L161
Issue has been created in prettier repo as well, attached here for tracking purpose. https://github.com/prettier/prettier/issues/4567
Adding error stack info below for our friend Google to route new comers to:
PR: https://github.com/vuejs/component-compiler-utils/pull/15