AWS Amplify 重复错误:重复的文件或模拟

Jus*_*ede 5 amazon-web-services amazon-dynamodb aws-lambda react-native aws-amplify

我设置了一个新的放大、添加了身份验证和确认后 lambda 函数,以将用户数据移至 DynamoDB。当我运行 NPM start 时,出现以下错误:

无法构造变压器:DuplicateError:重复的文件或模拟。请检查控制台以获取更多信息 setModule (\MyDemo\node_modules\jest-haste-map\build\index.js:543:17) .js:426:22 {

mockPath1: 'amplify#current-cloud-backend\function\FreshAuthPostConfirmation\src\package.json',

mockPath2: 'amplify\backend\function\FreshAuthPostConfirmation\src\package.json' } '''

根据我所读到的内容,#current-cloud-backend 是由 amplify 根据后端文件夹中的文件创建的。看起来 package.json 应该在那里,但我不确定为什么它是一个错误。我在某处看到我应该删除子类重复文件,我认为它是 #current-cloud-backend 中的文件,但是每次我推送它时 amplify 都会继续产生此错误,我如何避免这种情况到底发生了什么?

eli*_*li6 18

在Amplify GitHub Issue中有关于此错误的讨论。该文件package.json在 jest-haste-map 中出现两次,解决方案是#current-cloud-backend在构建和启动应用程序时显式忽略该文件夹。

问题的解决方案取决于您的 React Native 版本:在这里您可以找到有关不同版本的文件排除如何工作的概述。例如,您可以创建一个metro.config.js包含以下内容的文件来排除#current-cloud-backend

const exclusionList = require('metro-config/src/defaults/exclusionList');
module.exports = {
  resolver: {
    blacklistRE: exclusionList([/#current-cloud-backend\/.*/])
  }
};
Run Code Online (Sandbox Code Playgroud)

并安装metro-config为开发依赖项。如果这不起作用,您可以尝试链接中的一些其他解决方案。