首页 > 解决方案 > Metro 遇到错误“无法读取未定义反应本机的属性“transformFile”

问题描述

我只是想尝试 react-native。但是我得到这个错误。Metro 遇到错误:无法读取未定义的属性“transformFile”。我在我的物理设备和模拟器上尝试过,错误是一样的。我在我的控制台“无法构造转换器:错误:Node Sass 尚不支持您当前的环境:Windows 64-bit with Unsupported runtime (88)”中得到这个

第一个错误

第二个错误

这是我的 package.json 文件

{
  "name": "XYZ",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "prettier --write src/**/*.{ts,tsx} && eslint src/**/*.{ts,tsx}"
  },
  "husky": {
    "hooks": {
      "pre-commit": "yarn lint && yarn test"
    }
  },
  "dependencies": {
    "@apollo/react-hooks": "^3.1.5",
    "@react-native-community/async-storage": "^1.12.0",
    "@react-native-community/masked-view": "^0.1.10",
    "@react-native-community/netinfo": "^5.9.6",
    "@react-navigation/drawer": "^5.9.0",
    "@react-navigation/native": "^5.7.3",
    "@react-navigation/stack": "^5.9.0",
    "@types/react-native-auth0": "^2.5.0",
    "apollo-boost": "^0.4.9",
    "babel": "^6.23.0",
    "babel-core": "^6.26.3",
    "babel-upgrade": "^1.0.1",
    "date-fns": "^2.16.1",
    "metro-config": "^0.59.0",
    "react": "^16.13.1",
    "react-native": "^0.62.2",
    "react-native-auth0": "^2.5.0",
    "react-native-dotenv": "^0.2.0",
    "react-native-elements": "^2.2.1",
    "react-native-gesture-handler": "^1.8.0",
    "react-native-google-places-autocomplete": "^1.8.0",
    "react-native-linear-gradient": "^2.5.6",
    "react-native-reanimated": "^1.13.0",
    "react-native-safe-area-context": "^1.0.0",
    "react-native-screens": "^2.10.1",
    "react-native-skeleton-placeholder": "^2.0.7",
    "react-native-step-indicator": "^1.0.3",
    "react-native-svg": "^12.1.0",
    "react-native-swiper": "^1.6.0",
    "react-native-tab-view": "^2.15.1",
    "react-native-vector-icons": "^7.0.0",
    "reanimated-bottom-sheet": "^1.0.0-alpha.20"
  },
  "devDependencies": {
    "@babel/core": "^7.11.1",
    "@babel/runtime": "^7.11.2",
    "@react-native-community/eslint-config": "^1.0.0",
    "@types/jest": "^24.0.24",
    "@types/react-native": "^0.62.0",
    "@types/react-native-dotenv": "^0.2.0",
    "@types/react-test-renderer": "^16.9.3",
    "@typescript-eslint/eslint-plugin": "^2.34.0",
    "@typescript-eslint/parser": "^2.27.0",
    "babel-jest": "^24.9.0",
    "eslint": "^7.7.0",
    "eslint-config-airbnb-typescript": "^7.2.1",
    "eslint-config-prettier": "^6.11.0",
    "eslint-plugin-import": "^2.22.0",
    "eslint-plugin-jsx-a11y": "^6.3.1",
    "eslint-plugin-no-null": "^1.0.2",
    "eslint-plugin-prettier": "^3.1.4",
    "eslint-plugin-react": "^7.20.6",
    "eslint-plugin-react-hooks": "^4.1.0",
    "husky": "^4.2.5",
    "jest": "^26.4.0",
    "metro-react-native-babel-preset": "^0.58.0",
    "node-sass": "^4.14.1",
    "prettier": "^2.0.5",
    "react-native-sass-transformer": "^1.4.0",
    "react-native-svg-transformer": "^0.14.3",
    "react-test-renderer": "^16.13.1",
    "ts-jest": "^26.2.0",
    "typescript": "^3.9.7"
  }
}

标签: reactjsreact-nativereact-native-android

解决方案


我卸载了最新版本的节点并安装了节点的 LTS(长期支持),它开始工作


推荐阅读