无法在 Expo 中使用 React-Bootstrap(无法解析模块 react/jsx-runtime)
Can't use React-Bootstrap with Expo ( Unable to resolve module react/jsx-runtime )
我正在使用 Expo 构建一个 react-Native 应用程序,因此我尝试使用 bootstrap 库中的组件。我创建了一个新项目:
expo init test-app
然后我在项目文件夹中安装了库:
expo install react-bootstrap@next bootstrap@5.1.0
我得到了一些不相关警告的输出:
Installing 2 other packages using npm.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules\fsevents): npm WARN
notsup SKIPPING
OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted
{"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
added 24 packages from 48 contributors and audited 1045 packages in
9.112s
29 packages are looking for funding run npm fund
for details
found 8 vulnerabilities (6 low, 2 moderate) run npm audit fix
to
fix them, or npm audit
for details
我导入组件
import Button from 'react-bootstrap/Button';
但是当我编译时,显示如下信息:
Screenshot of the expo panel,
Unable to resolve module react/jsx-runtime from
C:\Users\Daniele\Documents\Coding\RipassoReact\test-app\node_modules\react-bootstrap\cjs\Button.js:
react/jsx-runtime could not be found within the project.
我尝试了很多方法,包括擦除 node_modules 文件夹并重新安装它们。
我该怎么办?
问题似乎是您正在尝试使用 Bootstrap,它适用于 React 但不适用于 React Native。
尝试找到支持您需求的不同库,例如 React Native Elements (https://reactnativeelements.com/) 或直接使用您从 React Native 获得的元素。
对我有用
npm install react-bootstrap
和
import { Button } from 'react-bootstrap';
我正在使用 Expo 构建一个 react-Native 应用程序,因此我尝试使用 bootstrap 库中的组件。我创建了一个新项目:
expo init test-app
然后我在项目文件夹中安装了库:
expo install react-bootstrap@next bootstrap@5.1.0
我得到了一些不相关警告的输出:
Installing 2 other packages using npm.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
added 24 packages from 48 contributors and audited 1045 packages in 9.112s
29 packages are looking for funding run
npm fund
for detailsfound 8 vulnerabilities (6 low, 2 moderate) run
npm audit fix
to fix them, ornpm audit
for details
我导入组件
import Button from 'react-bootstrap/Button';
但是当我编译时,显示如下信息: Screenshot of the expo panel,
Unable to resolve module react/jsx-runtime from C:\Users\Daniele\Documents\Coding\RipassoReact\test-app\node_modules\react-bootstrap\cjs\Button.js: react/jsx-runtime could not be found within the project.
我尝试了很多方法,包括擦除 node_modules 文件夹并重新安装它们。 我该怎么办?
问题似乎是您正在尝试使用 Bootstrap,它适用于 React 但不适用于 React Native。
尝试找到支持您需求的不同库,例如 React Native Elements (https://reactnativeelements.com/) 或直接使用您从 React Native 获得的元素。
对我有用
npm install react-bootstrap
和
import { Button } from 'react-bootstrap';