【发布时间】:2020-08-15 20:10:33
【问题描述】:
我想发布一个带有一些功能的 npm 包,以便在我的 create-react-app 项目中使用它。当我从 create-react-app 项目中的 js 文件导入函数时,它工作正常。但是当我将它作为 npm 包安装时,我收到一个错误:Support for the experimental syntax 'classProperties' isn't currently enabled。
我尝试将以下代码添加到 npm 包的 package.json 文件中:
"devDependencies": {
"@babel/plugin-proposal-class-properties": "^7.8.3"
},
"babel": {
"plugins": [
"@babel/plugin-proposal-class-properties"
]
}
但它并没有解决问题,我得到了同样的错误。
我还需要在我的 npm 包中添加什么依赖项才能在我的 create-react-app 项目中使用它?还是在没有这种实验性语法的情况下重写函数更好?
【问题讨论】:
标签: javascript node.js npm ecmascript-6 babeljs