Error: The 'decorators' plugin requires a 'decoratorsBeforeExport' option


Error: The ‘decorators’ plugin requires a ‘decoratorsBeforeExport’ option, whose value must be a boolean. If you are migrating from Babylon/Babel 6 or want to use the old decorators proposal, you should use the ‘decorators-legacy’ plugin instead of ‘decorators’ 背景:react 項目 + babel 7 + 使用到裝飾器 錯誤 使用以上裝飾器時,需安裝相應的插件和配置某些文件,否則可能會出現以下錯誤 解決辦法 步驟如下: 1、安裝以下插件 npm install -D @babel/plugin-proposal-decorators 1 2、配置.babelrc 文件或package.json文件的 babel 字段值(兩者二選一,不要都配置,否者會報找到兩個配置文件的錯) (1)配置 .babelrc 文件 "plugins": [ ["@babel/plugin-proposal-decorators", { "legacy": true }], ] 1 2 3 (2)配置 package.json 文件的 babel 字段值 babel: { "plugins": [ ["@babel/plugin-proposal-decorators", { "legacy": true }], ] } 1 2 3 4 5 參考文章 ‘decorators-legacy’ issue --------------------- 作者:Deng冬 來源:CSDN 原文:https://blog.csdn.net/dengdongxia/article/details/86819496 版權聲明:本文為博主原創文章,轉載請附上博文鏈接!


免責聲明!

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



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