每当我尝试在react-native中使用native-base时,我都会在终端上遇到以下错误
./node_modules/react-native-reanimated/lib/index.web.js 5:9 模块解析失败:意外的标记 (5:9) 文件是用这些加载器处理的:
默认从“./Animated”导出*;
=>这是我的 babe.config.js
module.exports = function (api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
plugins: [
'react-native-reanimated/plugin',
"nativewind/babel",
],
};
};
=>这是我的package.json
{
"name": "equb",
"version": "1.0.0",
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start --android",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web"
},
"dependencies": {
"@react-navigation/drawer": "^6.5.4",
"@react-navigation/native": "^6.1.1",
"expo": "~47.0.8",
"expo-linear-gradient": "~12.0.1",
"expo-status-bar": "~1.4.2",
"native-base": "^3.4.25",
"nativewind": "^2.0.11",
"react": "18.1.0",
"react-dom": "^18.2.0",
"react-native": "0.70.5",
"react-native-gesture-handler": "^2.8.0",
"react-native-reanimated": "^2.13.0",
"react-native-safe-area-context": "^3.3.2",
"react-native-svg": "^12.1.1",
"react-native-vector-icons": "^9.2.0",
"react-native-web": "^0.17.1",
"tailwindcss": "^3.2.4"
},
"devDependencies": {
"@babel/core": "^7.12.9"
},
"private": true
}
我已经安装了 native-base 并将我的所有项目包含在如下
export default function App() {
return (
<NativeBaseProvider>
<NavigationContainer>
<RootStack />
</NavigationContainer>
</NativeBaseProvider>
);
}
但错误仍然发生
强制安装
您也可以强制安装,但这可能会导致依赖关系损坏。
npm 安装react-native-animated-loader --force