No parser no filepath given問題解決


關於 vue 項目 run dev 的時候,控制台警告:

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

這個一般是配置問題,是vue-loader的問題。

不過有的說是 安裝 prettier 依賴,來控制代碼格式,好像沒用。

其實有個簡單的方法就是修改一下js文件:

去文件夾:

node_modules\vue-loader\lib\template-compiler\index.js

 下進行修改:

if (!isProduction) {       
    code = prettier.format(code, { semi: false})     
}

修改成:

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

OK,去重新run 一下


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM