No parser and no filepath given, using 'babel' the parser now but this will throw an error in t he f

nodejs搭建的vue项目,编译后在命令行发生警告:

No parser and no filepath given, using 'babel' the parser now but this will throw an error in t
he future. Please specify a parser or a filepath so one can be inferred.

可能原因是vue-loader的版本没跟上其他包的版本导致解析器不运行


(仅供参考)网上说是prettier版本的问题,普遍提供了两种解决办法:

方法一:

在package.json强制设置prettier的版本,降低为prettier1.12.1(个人感觉降级不太好)

方法二:

vue-loader@13.7.2 和vue-loader@14.2.3是已经修复了,等待发布新版可以解决,修复内容如下:(13.7.2版本下面试了,应该是没解决的prettier版本问题的

code = prettier.format(code, { semi: false, parser: 'babylon' })

指定了parser为babylon。


执行过的命令

npm install -S vue-loader@13.7.2

出现提示:需要将babylon 换成 babel 

解决办法:找到modules包里面的:node_modules\vue-loader\lib\template-compiler\index.js,将{ parser: "babylon" } 换成{ parser: "babel" } 即可

提示原因:prettier版本导致的

 

最终方案:【Vue-loader依赖的prettier报的问题,在14.2.4版本修复了】

然后更新到14.2.4,虽然当前最新的是15.6.5版本,不过从v14迁移到v15会有不少变更,配置不好也会报错,具体参见

https://vue-loader.vuejs.org/zh/migrating.html

Terminal执行命令:

npm install -S vue-loader@14.2.4

 更新vue-loader版本至14.2.4后,自动将{ parser: "babylon" } 换成{ parser: "babel" } 了

 


参考来源于:

https://blog.csdn.net/u011077672/article/details/87016308

https://blog.csdn.net/shan1991fei/article/details/81838115 

https://segmentfault.com/q/1010000018047642/

https://www.cnblogs.com/ruilin/p/11177873.html

  • 7
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值