简体   繁体   中英

Amplify: Expo Could not connect to development server

I have a React-Native app, using AWS Amplify that works with Expo when testing using expo start --web , but I am trying to test on my iOS device and get a Could not connect to development server. Error. URL: http://192.168.1.6:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=ios&dev=true&hot=false&minify=false

EDIT: I have tried starting a blank project, using amplify pull , and then this error occurs:

jest-haste-map: Haste module naming collision: projectamplifyjsc7fc9745PostConfirmation
  The following files share their name; please adjust your hasteImpl:
    * <rootDir>\amplify\#current-cloud-backend\function\projectamplifyjsc7fc9745PostConfirmation\src\package.json
    * <rootDir>\amplify\backend\function\projectamplifyjsc7fc9745PostConfirmation\src\package.json    

Failed to construct transformer:  DuplicateError: Duplicated files or mocks. Please check the console for more info
    at setModule (C:\Users\me\Desktop\project\node_modules\jest-haste-map\build\index.js:620:17)
    at workerReply (C:\Users\me\Desktop\project\node_modules\jest-haste-map\build\index.js:691:9)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Promise.all (index 50) {
  mockPath1: 'amplify\\#current-cloud-backend\\function\\projectamplifyjsc7fc9745PostConfirmation\\src\\package.json',
  mockPath2: 'amplify\\backend\\function\\projectamplifyjsc7fc9745PostConfirmation\\src\\package.json'}
Error: Duplicated files or mocks. Please check the console for more info
    at setModule (C:\Users\me\Desktop\project\node_modules\jest-haste-map\build\index.js:620:17)
    at workerReply (C:\Users\me\Desktop\project\node_modules\jest-haste-map\build\index.js:691:9)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Promise.all (index 50)
Error: Duplicated files or mocks. Please check the console for more info
    at setModule (C:\Users\me\Desktop\project\node_modules\jest-haste-map\build\index.js:620:17)
    at workerReply (C:\Users\me\Desktop\project\node_modules\jest-haste-map\build\index.js:691:9)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Promise.all (index 50)

What is this and how to fix?

This answer comes from someone who had a similar issue with the Amplify API, find it here: Amplify React Native - Duplicate Error using amplify add api

Solution is simple (at least for me, guess it could depend on what amplify services you use).

Amplify creates a copy of your current cloud backend configuration in amplify/#current-cloud-backend/ .

You don't need those files to build your app, so you can ignore them in order to get rid of the error.

To do so, you can create a blacklist and add the folder to it. Create a rn-cli.config.js file in the root of your project.

./rn-cli.config.js :

 require('metro').createBlacklist; const blacklist = require('metro-config/src/defaults/blacklist'); module.exports = { resolver: { blacklistRE: blacklist([/#current-cloud-backend\\/.*/]), }, }; ```

See answer given here: https://stackoverflow.com/a/60899723/11255886

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM