关于javascript:需要Babel“ ^ 7.0.0-0”,但在react-xml-parser软件包中已加载“ 6.26.3”-已经尝试了所有当前解决方案

Requires Babel “^7.0.0-0”, but was loaded with “6.26.3” on a react-xml-parser package - already tried all the current solutions

我已经尝试过Github社区针对此问题提供的许多解决方案,但似乎没有一个对我有用。

/node_modules/react-xml-parser/dist/bundle.js: Requires Babel"^7.0.0-0", but was loaded with"6.26.3". If you are sure you have a compatible version of @babel/core, it is likely that something in your build process is loading the wrong version. Inspect the stack trace of this error to look for the first entry that doesn't mention"@babel/core" or"babel-core" to see what is calling Babel. (While processing preset:"/Users/Brenor2/Documents/Freelas/ReiDasLiganetes/proj_ecommerce_reidasliganetes/mstore-expo/node_modules/@babel/preset-env/lib/index.js")

以下是我的package.json文件:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
  {
"name":"mstore",
"description":"MStore Pro - Complete React Native template for e-commerce",
"author":"InpireUI",
"version":"3.5.0",
"private": true,
"main":"node_modules/expo/AppEntry.js",
"scripts": {
 "setup":"./scripts/setup.sh"
},
"dependencies": {
 "@babel/core":"^7.0.0-beta.50",
 "api-ecommerce":"^0.0.5",
 "babel-plugin-transform-decorators-legacy":"^1.3.5",
 "base-64":"^0.1.0",
 "blob":"0.0.5",
 "currency-formatter":"^1.4.2",
 "datejs":"^1.0.0-rc3",
 "expo":"27.0.1",
 "firebase":"^5.0.1",
 "html-entities":"^1.2.1",
 "lodash":"4.17.10",
 "lottie-react-native":"^2.5.11",
 "moment":"^2.22.2",
 "monet":"^0.8.10",
 "oauth-1.0a":"1.0.1",
 "react":"16.4.1",
 "react-instantsearch":"^5.1.0",
 "react-native":"https://github.com/expo/react-native/archive/sdk-28.0.0.tar.gz",
 "react-native-animatable":"^1.3.0",
 "react-native-app-intro-slider":"^0.2.4",
 "react-native-awesome-alerts":"^1.2.0",
 "react-native-banner-carousel":"^1.0.3",
 "react-native-chart-kit":"^1.1.5",
 "react-native-collapsible":"0.12.0",
 "react-native-drawer":"https://github.com/luyx2412/react-native-drawer.git",
 "react-native-elements":"^0.19.1",
 "react-native-modal":"^7.0.2",
 "react-native-modalbox":"1.5.0",
 "react-native-parallax":"^0.3.0",
 "react-native-pure-chart":"0.0.24",
 "react-native-radio-buttons":"^1.0.0",
 "react-native-render-html":"3.10.0",
 "react-native-responsive-dimensions":"^1.0.2",
 "react-native-scrollable-tab-view":"^0.8.0",
 "react-native-side-menu":"^1.1.3",
 "react-native-snap-carousel":"^3.7.5",
 "react-native-star-rating":"^1.0.9",
 "react-native-swipe-list-view":"1.3.0",
 "react-native-swiper":"^1.5.13",
 "react-native-ui-kitten":"^3.1.2",
 "react-native-vector-icons":"4.6.0",
 "react-navigation":"2.5.5",
 "react-redux":"5.0.7",
 "react-xml-parser":"^1.0.8",
 "redux":"^4.0.0",
 "redux-persist":"^5.9.1",
 "redux-thunk":"^2.3.0",
 "reselect":"^3.0.1",
 "tcomb-form-native":"^0.6.13",
 "urijs":"1.19.1",
 "url":"^0.11.0",
 "url-parse":"1.4.1",
 "util":"0.11.0",
 "uuid":"3.3.2",
 "validate.js":"^0.12.0",
 "wpapi":"^1.1.2"
},
"devDependencies": {
 "@babel/core":"^7.4.0",
 "@babel/preset-env":"^7.4.1",
 "babel-core":"^7.0.0-bridge.0",
 "babel-jest":"^23.0.1",
 "babel-loader":"^8.0.5",
 "babel-plugin-transform-remove-console":"^6.9.4",
 "babel-preset-react-native":"4.0.0",
 "eslint":"^5.5.0",
 "eslint-config-airbnb":"^17.1.0",
 "eslint-config-google":"^0.9.1",
 "eslint-plugin-import":"^2.14.0",
 "eslint-plugin-jsx-a11y":"^6.1.1",
 "eslint-plugin-react":"^7.11.1",
 "jest":"^23.1.0",
 "react-test-renderer":"^16.4.0",
 "reactotron-react-native":"^1.14.0",
 "reactotron-redux":"^1.13.0",
 "webpack":"^4.29.6"
},  
"resolutions": {
 "babel-core":"7.0.0-bridge.0"
}

}

这是引发错误的包react-xml-parser的.babelrc文件(我必须手动将文件从" env"更改为" preset-env"):

1
{"presets": ["@babel/preset-env"] }


babel-plugin-transform-decorators-legacy用于Babel 6。

而是使用@babel/plugin-proposal-decorators并更新您的.babelrc

1
2
3
4
5
{
 "plugins": [
    ["@babel/plugin-proposal-decorators", {"legacy": true }],
  ]
}

https://github.com/loganfsmyth/babel-plugin-transform-decorators-legacy

您需要对babel7使用["@babel/plugin-proposal-decorators", {"legacy": true }]

babel7的大多数软件包都从babel-whatever-*重命名为@babel/whatever-*


最终,我解决了将react-xml-parser(导致错误的软件包)降级到较旧版本的问题,并且可以正常工作。
这是有道理的,因为此错误是在我对所有软件包进行的更新之后开始的。