javascript - 我该如何解决这个问题 : "node_modules/expo/AppEntry.js: [BABEL]"?

标签 javascript reactjs react-native dependencies expo

#node_modules/expo/AppEntry.js: [BABEL]

我已经为我的项目安装了所有依赖项,但我遇到了这个问题,我不确定如何解决它。

#package.json - 主要

{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "babel": "^6.23.0",
    "expo": "~39.0.2",
    "expo-status-bar": "~1.0.2",
    "react": "16.13.1",
    "react-dom": "16.13.1",
    "react-native": "https://github.com/expo/react-native/archive/sdk-39.0.4.tar.gz",
    "react-native-dotenv": "^2.4.2",
    "react-native-web": "~0.13.12"
  },
  "devDependencies": {
    "@babel/core": "~7.9.0",
    "babel-plugin-module-resolver": "^4.0.0"
  },
  "private": true,
  "name": "my-project"
}

enter image description here

最佳答案

正如 byCedric 指出的那样,检查了您的 GitHub 存储库,您的问题出在您使用的依赖项上。我进行了以下更改,该应用似乎可以正常运行,

截图:

enter image description here

package.json

{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "@react-native-community/picker": "^1.6.6",
    "expo": "~39.0.2",
    "expo-status-bar": "~1.0.2",
    "react": "16.13.1",
    "react-dom": "16.13.1",
    "react-native": "https://github.com/expo/react-native/archive/sdk-39.0.4.tar.gz",
    "react-native-dotenv": "^2.4.2",
    "react-native-fs": "^2.16.6",
    "react-native-web": "~0.13.12"
  },
  "devDependencies": {
    "@babel/core": "~7.9.0"
  },
  "private": true
}

安装上述所有依赖项后,我还遇到了以下文件的两个问题:

  1. node_modules\dotenv\lib\main.js
  2. node_modules\react-native-dotenv\index.js

他们使用的是 Node 标准库模块“fs”,所以我在上述两个文件中都将其替换为 react-native-fs 包。

修改后的两个文件:

//node_modules\dotenv\lib\main.js

const fs = require("react-native-fs")
const path = require('path')

function log (message /*: string */) {
  console.log(`[dotenv][DEBUG] ${message}`)
}
...

// node_modules\react-native-dotenv\index.js
const {readFileSync} = require("react-native-fs")
const dotenv = require('dotenv')

function parseDotenvFile(path, verbose = false) {
  let content
...

WeatherDetails.js 中也有错别字,您传递了 unitSystem 而不是 unitsSystem 作为 props

关于javascript - 我该如何解决这个问题 : "node_modules/expo/AppEntry.js: [BABEL]"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64747106/

相关文章:

JavaFX WebView 抛出异常

javascript - 如果我让所有数据对所有 Controller 可用,我会遇到什么问题?

javascript - Angular js : how to use ngMousedown ngMouseup

javascript - 如果页面未加载则执行代码

css - 如何在 Drawer - Material UI 中将 MenuItem 设置为事件状态?

javascript - 将启动屏幕添加到react-router-dom Reactjs项目

ios - 使用 NSURLSession 时无法调用 didReceiveData

Android SDK 未构建

javascript - React 模块和包装 Google Recaptcha

javascript - 无法在 ReactNative 文本框中输入文本