javascript - 内部错误 : Metro Bundler has encountered an internal error [Duplicate Module]

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

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

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

最佳答案

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

由于 ionic-input 相对较新,我想这在他的 repo 协议(protocol)中应该是一个问题。

无论如何,我想一个快速的解决方法是自己编辑/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"
  }

}

关于javascript - 内部错误 : Metro Bundler has encountered an internal error [Duplicate Module],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52566757/

相关文章:

javascript - Mongodb findOne 但首先检查请求是否为空

javascript - 将 optionRenderer 与 Select.Aysnc 结合使用( react 选择)

javascript - React 渲染一个空组件

javascript - 需要对一些基本设置进行一些说明

javascript - 在 Bootstrap 中组合固定宽度列和可变宽度列

javascript - 如何使用复选框来选中所有或取消选中所有框到 handsontable

node.js - 如何在 node.js 中的 next() 之后停止函数?

javascript - 在 AngularJS 指令中使用 Jquery 是好主意还是坏主意?

javascript - 如何创建点击事件以在不同的 HTML 页面上打开特定的 Bootstrap 选项卡?

angularjs - 环境标志已弃用