【问题标题】:Internal Error: Metro Bundler has encountered an internal error [Duplicate Module]内部错误:Metro Bundler 遇到内部错误 [重复模块]
【发布时间】:2019-03-05 03:01:09
【问题描述】:

我看到的错误是这样的:

我看到了很多关于这个错误的问题,但都是一些不同的上下文。我看到这个错误必须与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 上开发)

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

【问题讨论】:

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


    【解决方案1】:

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

    由于 ionic-input 相对较新,我想这值得在他的 repo 中提出。

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

    【讨论】:

    • 非常感谢。我该怎么做?我其实是新人。那么您可以编辑答案并显示在 package.json 中要进行的更改吗?
    • 当你这样做时,你能否删除在 YOUR_PROJECT/node_modules/ionic-input/node_modules 找到的 node_modules 文件,然后 cd 进入该目录并运行 npm install ?
    • 那肯定会的,请稍等
    • error: bundling failed: 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
    • 您能否尝试重置打包程序缓存:rm -fr $TMPDIR/react-*npm start --reset-cache。 ?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-27
    • 2019-10-08
    • 1970-01-01
    • 1970-01-01
    • 2021-11-22
    相关资源
    最近更新 更多