内部错误:Metro Bundler遇到内部错误[重复模块]

时间:2018-09-29 08:53:31

标签: javascript node.js reactjs react-native node-modules

我看到的错误是这样的:

This is the error I see

我看到了许多有关此错误的问题,但所有这些问题都在不同的上下文中出现。我发现此错误一定与node_modules中的名称冲突有关。 不重复


终端中的MetroBundler:

Loading dependency graph...(node:739) UnhandledPromiseRejectionWarning: Error: 
jest-haste-map: @providesModule naming collision:
  Duplicate module name: react-native
  Paths: /Users/iqubex/Sites/FidoDido/node_modules/react-native/package.json collides with /Users/iqubex/Sites/FidoDido/node_modules/iconic-input/node_modules/react-native/package.json

This error is caused by a @providesModule declaration with the same name across two different files.
    at setModule (/Users/iqubex/Sites/FidoDido/node_modules/react-native/node_modules/jest-haste-map/build/index.js:462:17)
    at workerReply (/Users/iqubex/Sites/FidoDido/node_modules/react-native/node_modules/jest-haste-map/build/index.js:512:9)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:739) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:739) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
::ffff:127.0.0.1 - - [29/Sep/2018:08:40:16 +0000] "GET /onchange HTTP/1.1" - - "-" "okhttp/3.10.0"

这是我的package.json

{
  "name": "fidodido",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "rnpm": {
    "assets": [
      "./app/assets/fonts/"
    ]
  },
  "dependencies": {
    "array-includes": "^3.0.3",
    "corejs": "^1.0.0",
    "es6-symbol": "^3.1.1",
    "firebase": "^5.4.0",
    "iconic-input": "^1.0.2",
    "native-base": "^2.7.2",
    "react": "16.4.1",
    "react-native": "^0.57.1",
    "react-navigation": "^2.11.2",
    "rn-sliding-up-panel": "^1.2.1"
  },
  "devDependencies": {
    "babel-jest": "23.4.2",
    "babel-preset-react-native": "^5",
    "jest": "23.5.0",
    "react-test-renderer": "16.4.1"
  },
  "jest": {
    "preset": "react-native"
  }
}

节点版本:v10.8.0 npm版本:v6.2.0 操作系统:Android(在Mac上开发)

我真的不知道周围发生了什么。看起来都坏了,无法正常工作。 请帮助!

1 个答案:

答案 0 :(得分:2)

问题似乎是ionic-input package.json文件列表将react-native作为依赖项而不是像所有其他react-native相关软件包一样将其列为devDependency。

由于离子输入相对较新,我想这应该在他的回购协议中解决。

无论如何,我想一个快速的解决方法是编辑/node_modules/ionic-input/package.json以将react-native用作devDependency

您可以尝试更改此(/node_modules/ionic-input/package.json):

{
  "name": "iconic-input",
  "version": "1.0.3",
  "description": "Beautiful Input components for React Native",
  "main": "index.js",
  "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
        "type": "git",
        "url": "https://www.github.com/KumarAbhirup/iconic-input"
  },
  "keywords": [
    "React",
    "React",
    "Native",
    "Javascript",
    "Node.js",
    "Component"
  ],
  "author": "Kumar Abhirup",
  "license": "ISC",
  "dependencies": {
    "native-base": "^2.7.2",
    "react": "^16.4.2",
    "react-native": "^0.56.0"
  }
}

进入此:

{
  "name": "iconic-input",
  "version": "1.0.3",
  "description": "Beautiful Input components for React Native",
  "main": "index.js",
  "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
        "type": "git",
        "url": "https://www.github.com/KumarAbhirup/iconic-input"
  },
  "keywords": [
    "React",
    "React",
    "Native",
    "Javascript",
    "Node.js",
    "Component"
  ],
  "author": "Kumar Abhirup",
  "license": "ISC",
  "dependencies": {
    "native-base": "^2.7.2",
    "react": "^16.4.2"
  },
  "devDependencies": {
    "react-native": "^0.56.0"
  }

}