模块解析失败:意外的令牌(11:19)

时间:2020-02-12 05:40:29

标签: react-native

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"
}

3 个答案:

答案 0 :(得分:4)

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

try {
    var fileContent = ""
    val file = File("/sdcard/Documents/my_confi_file.json")
    val fileInputStream = FileInputStream(file)
    val size = fileInputStream.available()
    val buffer = ByteArray(size)
    fileInputStream.read(buffer)
    fileContent = String(buffer, Charset.forName("UTF-8"))
    fileInputStream.close()
} catch (e: IOException) {
    e.printStackTrace()
}

答案 1 :(得分:0)

如评论中所述,没有webpack.config.js开头。因此,通过删除webpack作为依赖项,可以解决上述问题。

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

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

答案 2 :(得分:0)

我尝试了expo并在网络浏览器中运行,但存在相同的错误

这不起作用

“ npm卸载webpack && rm -rf node_modules && npm安装”