TypeError [ERR_INVALID_ARG_TYPE]:“路径”参数在React Native中必须为字符串类型

时间:2020-05-19 05:48:52

标签: node.js react-native

启动RN 0.62 / Node 12.16应用程序时,构建成功时出现捆绑错误。

info Reloading app...
info Opening developer menu...
[Mon May 18 2020 18:08:21.250]  BUNDLE  ./index.js

error: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type boolean (false)
    at validateString (internal/validators.js:117:11)
    at Object.dirname (path.js:583:5)
    at resolveFileOrDir (C:\D\code\js\ipat_js\node_modules\metro-resolver\src\resolve.js:256:24)
    at Object.resolve (C:\D\code\js\ipat_js\node_modules\metro-resolver\src\resolve.js:151:20)
    at ModuleResolver.resolveDependency (C:\D\code\js\ipat_js\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:143:31)
    at ResolutionRequest.resolveDependency (C:\D\code\js\ipat_js\node_modules\metro\src\node-haste\DependencyGraph\ResolutionRequest.js:52:18)
    at DependencyGraph.resolveDependency (C:\D\code\js\ipat_js\node_modules\metro\src\node-haste\DependencyGraph.js:287:16)
    at Object.resolve (C:\D\code\js\ipat_js\node_modules\metro\src\lib\transformHelpers.js:267:42)
    at C:\D\code\js\ipat_js\node_modules\metro\src\DeltaBundler\traverseDependencies.js:434:31
    at Array.map (<anonymous>)

在线上有几篇关于非常相似的错误的文章,但它们都是关于React或特定模块的。这是package.json

{
  "name": "ipat_js",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "@textile/ipfs-lite": "^0.1.6",
    "@tradle/react-native-http": "^2.0.0",
    "assert": "^1.1.1",
    "browserify-zlib": "^0.1.4",
    "buffer": "^4.9.1",
    "console-browserify": "^1.1.0",
    "constants-browserify": "^1.0.0",
    "dns.js": "^1.0.1",
    "domain-browser": "^1.1.1",
    "events": "^1.0.0",
    "https-browserify": "0.0.1",
    "path-browserify": "0.0.0",
    "process": "^0.11.0",
    "punycode": "^1.2.4",
    "querystring-es3": "^0.2.1",
    "react": "16.11.0",
    "react-native": "0.62.2",
    "react-native-crypto": "^2.1.0",
    "react-native-level-fs": "^3.0.0",
    "react-native-os": "^1.0.1",
    "react-native-randombytes": "^3.0.0",
    "react-native-tcp": "^3.2.1",
    "react-native-udp": "^2.1.0",
    "readable-stream": "^1.0.33",
    "stream-browserify": "^1.0.0",
    "string_decoder": "^0.10.31",
    "timers-browserify": "^1.0.1",
    "tty-browserify": "0.0.0",
    "url": "^0.10.3",
    "util": "^0.10.4",
    "vm-browserify": "0.0.4"
  },
  "devDependencies": {
    "@babel/core": "^7.9.6",
    "@babel/runtime": "^7.9.6",
    "@react-native-community/eslint-config": "^1.1.0",
    "babel-jest": "^25.5.1",
    "eslint": "^6.8.0",
    "jest": "^25.5.3",
    "metro-react-native-babel-preset": "^0.59.0",
    "react-test-renderer": "16.11.0",
    "rn-nodeify": "^10.2.0"
  },
  "jest": {
    "preset": "react-native"
  },
  "react-native": {
    "zlib": "browserify-zlib",
    "console": "console-browserify",
    "constants": "constants-browserify",
    "crypto": "react-native-crypto",
    "dns": "dns.js",
    "net": "react-native-tcp",
    "domain": "domain-browser",
    "http": "@tradle/react-native-http",
    "https": "https-browserify",
    "os": "react-native-os",
    "path": "path-browserify",
    "querystring": "querystring-es3",
    "fs": "react-native-level-fs",
    "_stream_transform": "readable-stream/transform",
    "_stream_readable": "readable-stream/readable",
    "_stream_writable": "readable-stream/writable",
    "_stream_duplex": "readable-stream/duplex",
    "_stream_passthrough": "readable-stream/passthrough",
    "dgram": "react-native-udp",
    "stream": "stream-browserify",
    "timers": "timers-browserify",
    "tty": "tty-browserify",
    "vm": "vm-browserify",
    "tls": false
  },
  "browser": {
    "zlib": "browserify-zlib",
    "console": "console-browserify",
    "constants": "constants-browserify",
    "crypto": "react-native-crypto",
    "dns": "dns.js",
    "net": "react-native-tcp",
    "domain": "domain-browser",
    "http": "@tradle/react-native-http",
    "https": "https-browserify",
    "os": "react-native-os",
    "path": "path-browserify",
    "querystring": "querystring-es3",
    "fs": "react-native-level-fs",
    "_stream_transform": "readable-stream/transform",
    "_stream_readable": "readable-stream/readable",
    "_stream_writable": "readable-stream/writable",
    "_stream_duplex": "readable-stream/duplex",
    "_stream_passthrough": "readable-stream/passthrough",
    "dgram": "react-native-udp",
    "stream": "stream-browserify",
    "timers": "timers-browserify",
    "tty": "tty-browserify",
    "vm": "vm-browserify",
    "tls": false
  }
}

我现在对此错误的线索不多。我该如何解决?

0 个答案:

没有答案