![](/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.