![](/img/trans.png)
[英]How to disable defining class properties in Babel + transform-decorators-legacy
[英]Unknown plugin “transform-decorators-legacy” error when using react storybook in windows
我将在Linux上创建的React项目克隆到我的Windows机器上。 该项目包括一些反应组件和一个故事书来测试这些组件。 “npm start”配置为在“package.json”文件中运行故事书:
“开始”:“npm run storybook”
键入“npm start”后,我在浏览器控制台上收到此错误:
“未捕获错误:模块构建失败:ReferenceError:未知插件”transform-decorators-legacy“在'C:\\ ... \\ node_modules \\ @storybo ok \\ ui \\ node_modules \\ react-treebeard \\ .babelrc'中指定”。 这是我的webpack.config.js文件(问题可能来自那里):
module.exports = (baseConfig, env) => {
const config = genDefaultConfig(baseConfig, env);
config.module.rules.push({
use: {
loader: 'babel-loader',
options: {
presets: [
['env', {
modules: false
}],
'react',
'flow'
],
plugins: [
'transform-class-properties',
'transform-object-rest-spread',
'flow-react-proptypes'
]
}
}
});
return config;
};
这些命令在linux / mac下运行时没有错误。 该问题仅发生在Windows上。
node v8.5.0 npm v5.4.2
我有同样的问题。 大多数人都说要确保在你的加载器部分中排除了包含babel的node_modules。
exclude: /node_modules/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.