简体   繁体   English

在React Native App启动中命名冲突

[英]Naming collision in react native app start

I'm using the out-of-the box react native framework to try to build a new app. 我正在使用开箱即用的反应本机框架来尝试构建新的应用程序。

i used the following commands ind CMD (Windows 10). 我在ind CMD(Windows 10)中使用了以下命令。

node -v: v8.12.0 节点-v:v8.12.0

npm -v: 6.4.1 npm -v:6.4.1

mkdir react-native-workspace mkdir react-native-workspace

cd react-native-workspace cd react-native-workspace

npm install -g create-react-native-app npm install -g create-react-native-app

create-react-native-app Exercise2 create-react-native-app练习2

cd Exercise2 cd练习2

npm start npm开始

ERROR 12:42 (node:15564) UnhandledPromiseRejectionWarning: Error: jest-haste-map: @providesModule naming collision: Duplicate module name: my-new-project Paths: C:\\Users\\wp_99\\Dokumenter\\react-native-workspace\\Exercise2\\package.json collides with C:\\Users\\wp_99\\Documents\\react-native-workspace\\Exercise2\\package.json 错误12:42(节点:15564)UnhandledPromiseRejectionWarning:错误:开玩笑的地图:@providesModule命名冲突:重复的模块名称:我的新项目路径:C:\\ Users \\ wp_99 \\ Dokumenter \\ react-native-workspace \\ Exercise2 \\ package.json与C:\\ Users \\ wp_99 \\ Documents \\ react-native-workspace \\ Exercise2 \\ package.json冲突

This error is caused by a @providesModule declaration with the same name across two different files. 此错误是由两个不同文件中具有相同名称的@providesModule声明引起的。 at setModule (C:\\Users\\wp_99\\Documents\\react-native-workspace\\Exercise2\\node_modules\\metro\\node_modules\\jest-haste-map\\build\\index.js:462:17) at workerReply (C:\\Users\\wp_99\\Documents\\react-native-workspace\\Exercise2\\node_modules\\metro\\node_modules\\jest-haste-map\\build\\index.js:512:9) at at process._tickCallback (internal/process/next_tick.js:189:7) ERROR 12:42 (node:15564) UnhandledPromiseRejectionWarning: Unhandled promise rejection. 在工作人员回复(C:\\ Users \\下)的setModule(C:\\ Users \\ wp_99 \\ Documents \\ react-native-workspace \\ Exercise2 \\ node_modules \\ metro \\ node_modules \\ jest-haste-map \\ build \\ index.js:462:17)下wp_99 \\ Documents \\ react-native-workspace \\ Exercise2 \\ node_modules \\ metro \\ node_modules \\ jest-haste-map \\ build \\ index.js:512:9)在进程中._tickCallback(内部/进程/next_tick.js:189: 7)错误12:42(节点:15564)UnhandledPromiseRejectionWarning:未处理的承诺拒绝。 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(). 引发此错误的原因可能是抛出了一个没有catch块的异步函数,或者是拒绝了一个.catch()无法处理的承诺。 (rejection id: 2) (node:15564) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. (拒绝ID:2)(节点:15564)[DEP0018] DeprecationWarning:已弃用未处理的承诺拒绝。 In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. 将来,未处理的承诺拒绝将以非零退出代码终止Node.js进程。

It's a bug in the metro-bundler. 这是地铁捆绑机中的错误。 You should create rn-cli.config.js and add this configuration to it: 您应该创建rn-cli.config.js并将此配置添加到其中:
For react-native>=0.57 对于本机> = 0.57

const blacklist = require('metro-config/src/defaults/blacklist');

module.exports = {
  resolver:{
    blacklistRE: blacklist([
      /nodejs-assets\/.*/,
      /android\/.*/,
      /ios\/.*/
    ])
  },
};  

react-native < 0.57 反应本征<0.57

const blacklist = require('metro/src/blacklist');

module.exports = {
  getBlacklistRE: function() {
    return blacklist([
      /nodejs-assets\/.*/,
      /android\/.*/,
      /ios\/.*/
    ]);
  },
};  

You can read more here . 您可以在这里阅读更多内容。

I've added the following to rn-cli.config.js 我在rn-cli.config.js中添加了以下内容

const blacklist = require('metro-config/src/defaults/blacklist');

module.exports = {
    resolver: {
        blacklistRE: blacklist([
            /node_modules\/.*\/node_modules\/react-native\/.*/,
        ])
    },
};

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Haste 模块命名冲突:将本机应用程序与 AWS 服务反应(放大项目) - Haste module naming collision: react native app with AWS Service (Amplify Project) 如何修复 React Native 错误“jest-haste-map:Haste 模块命名冲突”? - How to fix React Native error "jest-haste-map: Haste module naming collision"? 运行打包程序时React Native命名冲突错误,由“lodash”和“yeoman-generator”引起 - React Native naming collision error when running packager, caused by “lodash” and “yeoman-generator” React Native:由于 SoLoader 问题,应用程序在启动时崩溃 - React Native: App crashes on start due to SoLoader issue 根据React Native中的命名约定导入打字稿文件 - Import typescript files based on naming convention in React Native React-Native:使用AsyncStorage获取值并在应用程序/屏幕的“开始”处更新状态的正确方法是什么? - React-Native : what is the correct way to get a value with AsyncStorage and update the state at the “start” of an app/screen? 尝试通过 Expo (React Native) 启动应用程序时从 NodeJS 获取 EISDIR 错误 - Getting EISDIR error from NodeJS when attempting to start app via Expo (React Native) React Native 后端服务器启动错误 - React Native backend server start error 在React Native中使用道具启动计时器 - Using a prop to start a timer in React Native React Native:何时/如何启动网络请求? - React Native: When/how to start network requests?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM