反应本机应用程序启动时的命名冲突 [英] Naming collision in react native app start

查看:36
本文介绍了反应本机应用程序启动时的命名冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用开箱即用的 React Native 框架来尝试构建新应用.

我在 CMD (Windows 10) 中使用了以下命令.

节点-v:v8.12.0

npm -v:6.4.1

mkdir react-native-workspace

cd react-native-workspace

npm install -g create-react-native-app

create-react-native-app 练习 2

cd 练习 2

npm 启动

<块引用><块引用>

ERROR 12:42 (node:15564) UnhandledPromiseRejectionWarning:错误:jest-haste-map:@providesModule 命名冲突:重复模块名称:我的新项目路径:C:\Users\wp_99\Dokumenter\react-native-workspace\Exercise2\package.json与C:\Users\wp_99\Documents\react-native-workspace\Exercise2\package.json

这个错误是由@providesModule 声明引起的跨两个不同文件的名称.在 setModule (C:\Users\wp_99\Documents\react-native-workspace\Exercise2\node_modules\metro\node_modules\jest-haste-map\build\index.js:462:17)在 workerReply (C:\Users\wp_99\Documents\react-native-workspace\Exercise2\node_modules\metro\node_modules\jest-haste-map\build\index.js:512:9)在在 process._tickCallback (internal/process/next_tick.js:189:7) ERROR 12:42 (node:15564) UnhandledPromiseRejectionWarning: Unhandled承诺拒绝.此错误源于抛出内部没有 catch 块的异步函数,或者通过拒绝承诺这不是用 .catch() 处理的.(拒绝ID:2)(节点:15564)[DEP0018] 弃用警告:未处理的承诺拒绝是已弃用.将来,未处理的承诺拒绝将使用非零退出代码终止 Node.js 进程.

解决方案

我已将以下内容添加到 rn-cli.config.js

const blacklist = require('metro-config/src/defaults/blacklist');模块.出口 = {解析器:{blacklistRE:黑名单([/node_modules\/.*\/node_modules\/react-native\/.*/,])},};

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).

node -v: v8.12.0

npm -v: 6.4.1

mkdir react-native-workspace

cd react-native-workspace

npm install -g create-react-native-app

create-react-native-app Exercise2

cd Exercise2

npm start

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

This error is caused by a @providesModule declaration with the same name across two different files. 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. 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:15564) [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.

解决方案

I've added the following to rn-cli.config.js

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

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

这篇关于反应本机应用程序启动时的命名冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆