gpt4 book ai didi

javascript - 急速模块命名冲突 : react native app with AWS Service (Amplify Project)

转载 作者:行者123 更新时间:2023-12-03 17:57:17 25 4
gpt4 key购买 nike

我已经开始使用 react native 项目,之前是在本地代码中。
我想添加 Amazon Lex,所以按照链接中的以下步骤操作

https://aws-amplify.github.io/docs/js/interactions

下面是我的 App.js 文件

import React from 'react';
import { StyleSheet, Text, View } from 'react-native';

export default function App() {
return (
<View style={styles.container}>
<Text>Open up App.js to start working on your app!</Text>
</View>
);
}

const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});

我刚刚设置了放大库并为 LEX 添加了交互,但是当我尝试运行应用程序时开始出现错误。在添加之前工作正常......一旦创建了 Amplify 文件夹并开始出现后端错误......

(node:26180) UnhandledPromiseRejectionWarning: Error: jest-haste-map: Haste module naming collision: Duplicate module name: myamplifyproject_cfnlambda_87887b9a Paths: C:\Users\temp\Desktop\myAmplifyProject\amplify\backend\interactions\lex900662fd\src\package.json collides with C:\Users\temp\Desktop\myAmplifyProject\amplify#current-cloud-backend\interactions\lex900662fd\src\package.json

This error is caused by hasteImpl returning the same name for different files. at setModule (C:\Users\temp\Desktop\myAmplifyProject\node_modules\jest-haste-map\build\index.js:569:17) at workerReply (C:\Users\temp\Desktop\myAmplifyProject\node_modules\jest-haste-map\build\index.js:641:9) at processTicksAndRejections (internal/process/task_queues.js:93:5) at async Promise.all (index 30) ERROR 18:24 (node:26180) 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:26180) [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. (node:26180) UnhandledPromiseRejectionWarning: Error: jest-haste-map: Haste module naming collision: Duplicate module name: myamplifyproject_cfnlambda_87887b9a Paths: C:\Users\temp\Desktop\myAmplifyProject\amplify\backend\interactions\lex900662fd\src\package.json collides with C:\Users\temp\Desktop\myAmplifyProject\amplify#current-cloud-backend\interactions\lex900662fd\src\package.json

This error is caused by hasteImpl returning the same name for different files. at setModule (C:\Users\temp\Desktop\myAmplifyProject\node_modules\jest-haste-map\build\index.js:569:17) at workerReply (C:\Users\temp\Desktop\myAmplifyProject\node_modules\jest-haste-map\build\index.js:641:9) at processTicksAndRejections (internal/process/task_queues.js:93:5) at async Promise.all (index 30) (node:26180) 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: 3)



我已将所有最新版本用于 react-native。

我尝试了以下解决方案但无法正常工作 how to make react native packager ignore certain directories

我只是按照步骤......我哪里出错了......错过了任何东西......
请帮助......这是我第一个 react 原生的应用程序......我实际上迷路了

最佳答案

经过许多不眠之夜和测试不同的解决方案,我终于能够通过..我使用最新的 react-native > 0.59(我猜是 0.61)
我的应用程序已经在根目录创建了 metro.config.js 文件,必须编辑相同的文件。

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

resolver: {
blacklistRE: blacklist([/#current-cloud-backend\/.*/]) //add within module export
}

我呼吸了新鲜空气……现在一切正常……

请不要创建新的 metro.config.js 或 rn-cli.config.js。使用 编辑当前的 metro.config.js #current-cloud-backend 不是 后台文件夹。这个非常重要。
后端将被忽略....

这将对将来的某人有所帮助....因为给出的解决方案都不起作用....对于最新的 native react 。

关于javascript - 急速模块命名冲突 : react native app with AWS Service (Amplify Project),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58838038/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com