Amplify-cli: Generating REST API and Function via Amplify Add API results in naming collision

Created on 28 Mar 2019  路  4Comments  路  Source: aws-amplify/amplify-cli

Describe the bug
When generating a REST API via the amplify add apicommand, the packager cannot be run again due to the following error:

Loading dependency graph...(node:18727) UnhandledPromiseRejectionWarning: Error: jest-haste-map: Haste module naming collision:
  Duplicate module name: functionsendalertsms
  Paths: /Users/kirkryan/Documents/dev/Native/amplify/backend/function/functionsendalertsms/src/package.json collides with /Users/kirkryan/Documents/dev/Native/amplify/#current-cloud-backend/function/functionsendalertsms/src/package.json

To Reproduce
Steps to reproduce the behaviour:

  1. Run ampify add api, select REST, edit lambda function and then amplify push
  2. Run yarn start to start packager
  3. See error

Expected behavior
Packager would start normally

Desktop (please complete the following information):

  • OS: macOS Mojave 10.14.3
  • Browser Chrome
  • Version 73.0.3683.86

Smartphone (please complete the following information):

  • Device: iPhone XS
  • OS: iOS 12.1.4
  • Browser Safari

Additional context
AWS Amplify: 0.1.43 (the result of amplify version command)
node.js version: v10.1.0

documentation functions investigating

Most helpful comment

we encountered this issue on a react-native ^0.61.x project after a amplify add function command. Adding a resolver blacklist to the metro.config.js:

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

module.exports = {
  resolver: {
    blacklistRE: blacklist([/amplify\/#current-cloud-backend\/.*/]),
  },
  transformer: {
    getTransformOptions: async () => ({
      transform: {
        experimentalImportSupport: false,
        inlineRequires: false,
      },
    }),
  },
};

and restarting the process yarn start --reset-cache with a cache reset eliminated the error

All 4 comments

Hello,

I have the same issue:

(node:39314) UnhandledPromiseRejectionWarning: Error: jest-haste-map: Haste module naming collision:
Duplicate module name: MedicosCRUDFunction
Paths: /Users/rlousada/Documents/Developer/react-native/awstest2/amplify/backend/function/MedicosCRUDFunction/src/package.json collides with /Users/rlousada/Documents/Developer/react-native/awstest2/amplify/#current-cloud-backend/function/MedicosCRUDFunction/src/package.json

with the following services added

| Category | Resource name | Operation | Provider plugin |
| -------- | ------------------- | --------- | ----------------- |
| Auth | cognito47ff28f4 | No Change | awscloudformation |
| Storage | BetterNow | No Change | awscloudformation |
| Function | MedicosCRUDFunction | No Change | awscloudformation |
| Api | BetterNow | No Change | awscloudformation |

Any particular solution?

Yeah a turns out you have to exclude one of the directories from the bundler - Fix is here: https://github.com/aws/awsmobile-cli/issues/172#issuecomment-410931468

we encountered this issue on a react-native ^0.61.x project after a amplify add function command. Adding a resolver blacklist to the metro.config.js:

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

module.exports = {
  resolver: {
    blacklistRE: blacklist([/amplify\/#current-cloud-backend\/.*/]),
  },
  transformer: {
    getTransformOptions: async () => ({
      transform: {
        experimentalImportSupport: false,
        inlineRequires: false,
      },
    }),
  },
};

and restarting the process yarn start --reset-cache with a cache reset eliminated the error

I have the exact same issue but sadly the above solution didn't work for me :(

The error message: Loading dependency graph...(node:18727) UnhandledPromiseRejectionWarning: Error: jest-haste-map: Haste module naming collision:
....
....
still shows. I will note that I could not find the metro.config.json file in my root, rather it was in this path: node_modules -> react native -> template -> metro.config.json
https://github.com/facebook/react-native/blob/0.59-stable/template/metro.config.js#L12-L13

I am also using react native 0.59, but just recently upgraded to 0.61.5

Any suggestions on the problem?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jexh picture jexh  路  3Comments

kstro21 picture kstro21  路  3Comments

davo301 picture davo301  路  3Comments

nicksmithr picture nicksmithr  路  3Comments

darrentarrant picture darrentarrant  路  3Comments