我有一个带有Expo的create-react-native-app应用程序,并且想要安装节点模块react-native-appearance以根据OS设置切换该应用程序主题。
这是我来自App.js的代码
import React from "react";
import AppContainer from "./navigation/navigation";
import { AppearanceProvider,useColorScheme } from "react-native-appearance";
export default class App extends React.Component {
render() {
let theme = useColorScheme();
return (
<AppearanceProvider>
<AppContainer theme={theme} />
</AppearanceProvider>
);
}
}
这是错误:
While trying to resolve module 'react-native-appearance' from file **/**/**/App.js,the
package **/**/**//node_modules/react-native-appearance/package.json` was successfully
found. However,this package itself specifies a `main`module field that could not be
resolved (`/***/****/****/****/****/****/node_modules/react-native-
appearance/src/index`. Indeed,none of these files exist:
/Users/mbolender/Productive/project/frontend/frontend/node_modules/
react-native-appearance/src/index(.native|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|
.jsx|.ios.scss|.native.scss|.scss|.ios.sass|.native.sass|.sass|.ios.json|.native.json|.json
/Users/mbolender/Productive/project/frontend/frontend/node_modules/react-native-appearance
/src/index/index(.native|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|
.jsx|.ios.scss|.native.scss|.sass.ios.json|.native.json|.json
Failed building JavaScript bundle.
我已经按照解决方案删除./node_modules +关闭expo生成器并重新安装./node_modules。但这没有帮助