node_modules/expo/AppEntry.js:Transformer.transform不是函数 [英] node_modules/expo/AppEntry.js: Transformer.transform is not a function

查看:176
本文介绍了node_modules/expo/AppEntry.js:Transformer.transform不是函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几天来我一直在寻找解决这个问题的方法,我认为这与我升级到最新版本的expo有关.我尝试降级SDK和expo版本,删除我的node_modules并进行包锁定,然后重新安装.我已经在SourceExts中添加了我的app.json.

任何帮助将不胜感激.该应用程序可在网络浏览器中运行,但无法为iO或android模拟器构建.

app.json

{
  "expo": {
    "name": "GotThis",
    "slug": "GotThis",
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/icon.png",
    "splash": {
      "image": "./assets/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": ["**/*"],
    "ios": {
      "supportsTablet": true
    },
    "web": {
      "favicon": "./assets/favicon.png"
    },
    "packagerOpts": {
      "sourceExts": ["js", "json", "ts", "tsx", "jsx"]
    }
  }
}

package.json

{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "test": "jest",
    "eject": "expo eject"
  },
  "dependencies": {
    "expo": "~38.0.8",
    "expo-status-bar": "^1.0.2",
    "react": "~16.11.0",
    "react-dom": "~16.11.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-38.0.2.tar.gz",
    "react-native-elements": "^2.0.4",
    "react-native-paper": "^4.0.1",
    "react-native-web": "~0.11.7"
  },
  "devDependencies": {
    "@babel/core": "^7.10.5",
    "babel-preset-expo": "^8.1.0",
    "jest-expo": "^38.0.2",
    "metro": "^0.60.0",
    "metro-react-native-babel-preset": "^0.59.0",
    "react-test-renderer": "^16.13.1"
  },
  "jest": {
    "preset": "jest-expo",
    "transformIgnorePatterns": [
      "node_modules/(?!(jest-)?react-native|react-clone-referenced-element|@react-native-community|expo(nent)?|@expo(nent)?/.*|react-navigation|@react-navigation/.*|@unimodules/.*|unimodules|sentry-expo|native-base|@sentry/.*)"
    ]
  },
  "private": true
}

node_modules/expo/AppEntry.js

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

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

registerRootComponent(App);

android模拟器中的错误 android错误

解决方案

经过大量研究,我得出的结论是问题是由Metro-config软件包的版本不匹配引起的.如果您在应用中依靠它来覆盖某些默认的Metro配置,则应确保它与react-native所依赖的版本相同.就我而言,我使用的是metro@0.61.0,由于react-native@0.62.2取决于metro@0.58.0,所以我所做的就是将Metro版本从@ 0.61.0降级为@ 0.58.0.

您可以通过运行npm ls metro-config或搜索package-lock.json文件来检查哪些版本需要安装.

我遵循了这个有用的线程,您可以检查该线程是否解决方案对您不起作用.

I've been looking for a solution to this problem for a couple of days now and I think it has something to do with my upgrade to the latest version of expo. I've tried downgrading the SDK and expo version, deleting my node_modules and package-lock and reinstalling. I've added in SourceExts to my app.json.

Any help would be appreciated. The app works in the web browser but won't build for iOs or android simulators.

app.json

{
  "expo": {
    "name": "GotThis",
    "slug": "GotThis",
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/icon.png",
    "splash": {
      "image": "./assets/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": ["**/*"],
    "ios": {
      "supportsTablet": true
    },
    "web": {
      "favicon": "./assets/favicon.png"
    },
    "packagerOpts": {
      "sourceExts": ["js", "json", "ts", "tsx", "jsx"]
    }
  }
}

package.json

{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "test": "jest",
    "eject": "expo eject"
  },
  "dependencies": {
    "expo": "~38.0.8",
    "expo-status-bar": "^1.0.2",
    "react": "~16.11.0",
    "react-dom": "~16.11.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-38.0.2.tar.gz",
    "react-native-elements": "^2.0.4",
    "react-native-paper": "^4.0.1",
    "react-native-web": "~0.11.7"
  },
  "devDependencies": {
    "@babel/core": "^7.10.5",
    "babel-preset-expo": "^8.1.0",
    "jest-expo": "^38.0.2",
    "metro": "^0.60.0",
    "metro-react-native-babel-preset": "^0.59.0",
    "react-test-renderer": "^16.13.1"
  },
  "jest": {
    "preset": "jest-expo",
    "transformIgnorePatterns": [
      "node_modules/(?!(jest-)?react-native|react-clone-referenced-element|@react-native-community|expo(nent)?|@expo(nent)?/.*|react-navigation|@react-navigation/.*|@unimodules/.*|unimodules|sentry-expo|native-base|@sentry/.*)"
    ]
  },
  "private": true
}

node_modules/expo/AppEntry.js

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

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

registerRootComponent(App);

Error in the android emulator android error

解决方案

After much research, I have come to a conclusion where the problem was caused by a version mismatch of the metro-config package. if you depend on this in your app to override some default metro configuration you should make sure it's the same version react-native depends on. In my case, I was using metro@0.61.0 and since react-native@0.62.2 depends on metro@0.58.0 all I did is I downgraded the metro version from @0.61.0 to @0.58.0.

You can check which versions are required and installed by running npm ls metro-config or searching the package-lock.json file.

I have followed this useful thread which you can check out if this solution didn't work for you.

这篇关于node_modules/expo/AppEntry.js:Transformer.transform不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆