【问题标题】:I'm getting this error while running the code in React Native error : node_modules\expo\AppEntry.js: [BABEL]: Cannot find module 'node:path'在 React Native 错误中运行代码时出现此错误:node_modules\\expo\\AppEntry.js: [BABEL]: Cannot find module \'node:path\'
【发布时间】:2022-11-12 00:55:31
【问题描述】:

使用 Tailwind 在 React Native expo 中运行代码时出现此错误

Android Bundling failed 25ms error:node_modules\expo\AppEntry.js: [BABEL]: Cannot find module 'node:path' Require stack: C:\Users\HPX\ipx\node_modules\nativewind\dist\babel\index.js C:\Users\HPX\ipx\node_modules\nativewind\babel.js C:\Users\HPX\ipx\node_modules@babel\core\lib\config\files\module-types.js C:\Users\HPX\ipx\node_modules@babel\core\lib\config\files\configuration.js C:\Users\HPX\ipx\node_modules@babel\core\lib\config\files\index.js C:\Users\HPX\ipx\node_modules@babel\core\lib\index.js C:\Users\HPX\ipx\node_modules\metro-transform-worker\src\index.js C:\Users\HPX\ipx\node_modules\metro\src\DeltaBundler\Worker.flow.js C:\Users\HPX\ipx\node_modules\metro\src\DeltaBundler\Worker.js C:\Users\HPX\ipx\node_modules\jest-worker\build\workers\processChild.js (While processing: C:\Users\HPX\ipx\node_modules\nativewind\babel.js)


这是我的AppEntry.js文件 :

import registerRootComponent from 'expo/build/launch/registerRootComponent';

import App from '../../App';

registerRootComponent(App);

这是我的包.json文件 :

{
  "name": "ipx",
  "version": "1.0.0",
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web"
  },
  "dependencies": {
    "expo": "~47.0.3",
    "expo-status-bar": "~1.4.2",
    "nativewind": "^2.0.11",
    "react": "18.1.0",
    "react-native": "0.70.5",
    "tailwindcss": "^3.2.3"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9"
  },
  "private": true
}

如果您对此有解决方案,请重播

【问题讨论】:

    标签: node.js react-native expo tailwind-css


    【解决方案1】:

    您不能直接将 TailWind CSS 与 react native 一起使用,因为 HTML 和 ReactNative 的样式不同,您可以使用一些库,例如 twrnc

    【讨论】:

      【解决方案2】:

      当您安装 NativeWind 时,您的控制台中出现错误,表明您的 Node 版本不符合最低要求。您需要更新到 >=14.18

        "engines": {
          "node": ">=14.18"
        },
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2022-09-28
        • 2021-02-21
        • 2019-06-30
        • 1970-01-01
        • 2023-02-04
        • 1970-01-01
        • 1970-01-01
        • 2021-09-12
        相关资源
        最近更新 更多