【问题标题】:Module parse failed: Unexpected token (11:19)模块解析失败:意外令牌 (11:19)
【发布时间】:2020-02-12 05:40:29
【问题描述】:

web 编译失败。 C:/XXX/node_modules/galio-framework/src/Toast.js 11:19 模块解析失败:意外令牌 (11:19) 您可能需要适当的加载程序来处理此文件类型,目前没有配置加载程序来处理此文件。见https://webpack.js.org/concepts#loaders | |类 Toast 扩展组件 {

静态 propTypes = { |孩子:PropTypes.node.isRequired, | isShow: PropTypes.bool.isRequired,

{
  "name": "Bay",
  "version": "1.3.0",
  "description": "Desc",
  "scripts": {
    "start": "react-native start",
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "postinstall": "jetify"
  },
  "repository": {
    "type": "git",
    "url": "git+https://gx.git"
  },
  "dependencies": {
    "expo": "^35.0.0",
    "expo-asset": "~7.0.0",
    "expo-font": "~7.0.0",
    "galio-framework": "^0.6.3",
    "prop-types": "^15.7.2",
    "react": "16.8.3",
    "react-dom": "16.8.3",
    "react-native": "0.59.10",
    "react-native-gesture-handler": "~1.3.0",
    "react-native-modal-dropdown": "^0.6.2",
    "react-native-reanimated": "~1.3.0",
    "react-native-screens": "1.0.0-alpha.23",
    "react-native-unimodules": "0.6.0",
    "react-native-web": "^0.11.7",
    "react-navigation": "^3.11.0",
    "webpack": "^4.41.6"
  },
  "devDependencies": {
    "@babel/core": "^7.6.0",
    "babel-jest": "24.9.0",
    "jest": "24.9.0",
    "jetifier": "^1.6.4",
    "metro-react-native-babel-preset": "0.56.0",
    "react-test-renderer": "16.9.0",
    "babel-preset-expo": "^7.0.0"
  },
  "keywords": [
    "argon react native",
    "argon design system",
    "argon app react native",
    "argon iOS",
    "react native iOS",
    "creative tim",
    "argon Android",
    "react native ui kit",
    "react native expo",
    "freebie",
    "react native argon design",
    "react native galio",
    "galio argon free",
    "galio react native free app",
    "argon expo react native",
    "react native ui template"
  ],
  "author": "ss",
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/creativetimofficial/argon-react-native/issues"
  },
  "homepage": "https://demos.creative-tim.com/argon-react-native"
}

【问题讨论】:

  • 你能分享你的webpack.config.js吗?
  • @kenmistry 我是新来反应原生的。项目位置上没有名为 webpack.config.js 的文件。我错过了 webpack 的任何 npm 插件吗?
  • 如果webpack.config.js 文件不存在,您遇到此问题很奇怪,因为安装webpack 应该最初为您设置文件。它可以是您执行的包含webpack 的命令。也许,删除任何 webpack 命令应该可以解决问题。
  • @kenmistry what kind of webpack 命令从项目目录中删除以解决问题
  • expo sdk 错误通过命令npm install -g expo-cli.expo 服务器安装expo clii 解决,应该开始运行应用程序

标签: react-native


【解决方案1】:

如果您使用的是 Expo,我在 app.json 中添加了以下内容:

"web": {
  "build": {
    "babel": {
      "include": ["galio-framework"]
    }
  }
}

【讨论】:

  • 谢谢,重启服务器后就可以了
【解决方案2】:

正如 cmets 中所讨论的,没有 webpack.config.js 开头。因此,通过删除 webpack 作为依赖项,上述问题得到解决。

要删除 webpack 并重新安装,请运行以下命令:

npm uninstall webpack && rm -rf node_modules && npm install

【讨论】:

    猜你喜欢
    • 2023-03-27
    • 2019-02-15
    • 2021-04-26
    • 2021-05-01
    • 2020-11-16
    • 2021-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多