![](/img/trans.png)
[英]bundling failed: Error: Cannot find module 'babel-preset-react-native-stage-0/decorator-support'
[英]react native transform - error couldn't find preset "babel-preset-react-native-stage-0
我開始彈出世博會,經過這么多的努力,我能夠解決所有構建問題。 當我使用'sudo react-native run-android'運行應用程序時,我開始收到以下錯誤
錯誤:
The development server returned response code 500
Bundling `index.android.js` [development, non-minified, hmr disabled]
0.0% (0/1), failed.
error: bundling failed: "TransformError:
/Development/SourceCode/MobileApp/index.android.js:
Couldn't find preset \"babel-preset-react-native-stage-0/decorator-support\" relative to directory \"/Development/SourceCode/MobileApp\""
我嘗試了在github和SO中給出的幾乎所有可能的修復
.babelrc
文件看起來像這樣
{
"presets": [
"react-native",
"babel-preset-react-native-stage-0/decorator-support"
],
"env": {
"development": {
"plugins": [
"transform-react-jsx-source"
]
}
}
}
這些修復都不適合我。 使用babel-preset-react-native@2.1.0
也沒有解決問題,因為這是主要修復。
嘗試使用正常的babel預設0: https : //babeljs.io/docs/plugins/preset-stage-0
所以
"presets": ["react-native", "stage-0"]
如果您可以使用舊版本的React Native,可以使用以下內容在項目的根目錄中創建.babelrc文件:
{
"presets": ["react-native"]
}
如果您在項目中使用了Expo,
嘗試:
cd your_project
nano .babelrc
(或者你想要的任何編輯器) 如果您的項目中沒有.babelrc,那么:
$ cd your_project
touch .babelrc
{
"presets": ["babel-preset-expo"],
"env": {
"development": {
"plugins": ["transform-react-jsx-source"]
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.