【问题标题】:React Native Error on building Expo Project在构建 Expo 项目时反应本机错误
【发布时间】:2020-04-30 06:57:24
【问题描述】:

我有一个带有 Expo 的 create-react-native-app 应用程序,并想安装节点模块 react-native-appearance 以根据操作系统设置切换应用程序主题。

这是我的 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 builder 并重新安装 ./node_modules。但这并没有帮助

【问题讨论】:

    标签: react-native npm expo node-modules


    【解决方案1】:

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

    你的情况试试这个:

    npm uninstall react-native-appearance

    expo install react-native-appearance

    【讨论】:

    • 感谢您的回答!我卸载了react-native-appearance 并做了expo install react-native-appearance。但是出现同样的错误
    猜你喜欢
    • 1970-01-01
    • 2021-12-11
    • 2022-11-09
    • 2015-12-23
    • 2021-10-01
    • 2019-09-09
    • 2021-08-25
    • 1970-01-01
    • 2018-07-24
    相关资源
    最近更新 更多