在构建Expo Project时反应本机错误

我有一个带有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。但这没有帮助

yu_yi2009 回答:在构建Expo Project时反应本机错误

所有由expo管理的项目都需要使用expo install安装受expo支持的软件包,否则,如果您有裸露的应用程序,则可以使用npm i

搞砸了,试试这个:

npm uninstall react-native-appearance

expo install react-native-appearance

本文链接:https://www.f2er.com/2777257.html

大家都在问