Solucionado (ver solução)
Solucionado
(ver solução)
9
respostas

Erro ao executar comando run-android.

Eu executei o "react-native start" e o "react-native run-android" mas gente na hora que abro o aplicativo no emulador , abre um tela vermelha com esse conteudo:

The development server returned response error code: 500

URL: http://10.0.2.2:8081/index.delta?platform=android&dev=true&minify=false

Body:
{"originModulePath":"C:\\Users\\rafael.scharf\\Documents\\curso\\REACT\\InstaluraMobile\\index.js","targetModuleName":"@babel/runtime/helpers/interopRequireDefault","message":"Unable to resolve module `@babel/runtime/helpers/interopRequireDefault` from `C:\\Users\\rafael.scharf\\Documents\\curso\\REACT\\InstaluraMobile\\index.js`: Module `@babel/runtime/helpers/interopRequireDefault` does not exist in the Haste module map\n\nThis might be related to https://github.com/facebook/react-native/issues/4968\nTo resolve try the following:\n  1. Clear watchman watches: `watchman watch-del-all`.\n  2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.\n  3. Reset Metro Bundler cache: `rm -rf /tmp/metro-bundler-cache-*` or `npm start -- --reset-cache`.\n  4. Remove haste cache: `rm -rf /tmp/haste-map-react-native-packager-*`.","errors":[{"description":"Unable to resolve module `@babel/runtime/helpers/interopRequireDefault` from `C:\\Users\\rafael.scharf\\Documents\\curso\\REACT\\InstaluraMobile\\index.js`: Module `@babel/runtime/helpers/interopRequireDefault` does not exist in the Haste module map\n\nThis might be related to https://github.com/facebook/react-native/issues/4968\nTo resolve try the following:\n  1. Clear watchman watches: `watchman watch-del-all`.\n  2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.\n  3. Reset Metro Bundler cache: `rm -rf /tmp/metro-bundler-cache-*` or `npm start -- --reset-cache`.\n  4. Remove haste cache: `rm -rf /tmp/haste-map-react-native-packager-*`."}],"name":"Error","stack":"Error: Unable to resolve module `@babel/runtime/helpers/interopRequireDefault` from `C:\\Users\\rafael.scharf\\Documents\\curso\\REACT\\InstaluraMobile\\index.js`: Module `@babel/runtime/helpers/interopRequireDefault` does not exist in the Haste module map\n\nThis might be related to https://github.com/facebook/react-native/issues/4968\nTo resolve try the following:\n  1. Clear watchman watches: `watchman watch-del-all`.\n  2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.\n  3. Reset Metro Bundler cache: `rm -rf /tmp/metro-bundler-cache-*` or `npm start -- --reset-cache`.\n  4. Remove haste cache: `rm -rf /tmp/haste-map-react-native-packager-*`.\n    at ModuleResolver.resolveDependency (C:\\Users\\rafael.scharf\\Documents\\curso\\REACT\\InstaluraMobile\\node_modules\\metro\\src\\node-haste\\DependencyGraph\\ModuleResolution.js:209:1301)\n    at ResolutionRequest.resolveDependency (C:\\Users\\rafael.scharf\\Documents\\curso\\REACT\\InstaluraMobile\\node_modules\\metro\\src\\node-haste\\DependencyGraph\\ResolutionRequest.js:83:16)\n    at DependencyGraph.resolveDependency (C:\\Users\\rafael.scharf\\Documents\\curso\\REACT\\InstaluraMobile\\node_modules\\metro\\src\\node-haste\\DependencyGraph.js:238:485)\n    at Object.resolve (C:\\Users\\rafael.scharf\\Documents\\curso\\REACT\\InstaluraMobile\\node_modules\\metro\\src\\lib\\transformHelpers.js:180:25)\n    at dependencies.map.result (C:\\Users\\rafael.scharf\\Documents\\curso\\REACT\\InstaluraMobile\\node_modules\\metro\\src\\DeltaBundler\\traverseDependencies.js:311:29)\n    at Array.map (<anonymous>)\n    at resolveDependencies (C:\\Users\\rafael.scharf\\Documents\\curso\\REACT\\InstaluraMobile\\node_modules\\metro\\src\\DeltaBundler\\traverseDependencies.js:307:16)\n    at C:\\Users\\rafael.scharf\\Documents\\curso\\REACT\\InstaluraMobile\\node_modules\\metro\\src\\DeltaBundler\\traverseDependencies.js:164:33\n    at Generator.next (<anonymous>)\n    at step (C:\\Users\\rafael.scharf\\Documents\\curso\\REACT\\InstaluraMobile\\node_modules\\metro\\src\\DeltaBundler\\traverseDependencies.js:266:307)"}
processBundleResult
    BundleDownloader.java:296
access$200
    BundleDownloader.java:37
onResponse
    BundleDownloader.java:174
execute
    RealCall.java:153
run
    NamedRunnable.java:32
runWorker
    ThreadPoolExecutor.java:1113
run
    ThreadPoolExecutor.java:588
run
    Thread.java:818
9 respostas

Oi Rafael, tudo bom?

Pela mensagem de erro, parece que é um bug famoso. Na própria mensagem segue o que pode ser feito:

1. Limpar o watchman: `watchman watch-del-all`.

2. Deletar a pasta node_modules: `rm -rf node_modules && npm install`.

3. Resetar o cache do Metro Bundler: `rm -rf /tmp/metro-bundler-cache-*` or `npm start -- --reset-cache`.

4. Remover o cache do haste: `rm -rf /tmp/haste-map-react-native-packager-*`

O único comando que funcionou no cmd foi o 3 mas o 1, 2 e 4 dizem que o comando interno não existe. O problema ainda persiste. Segue as imagens abaixo do CMD e do Emulador

1 - cmd: https://imgur.com/uqVPEHS

2 - cmd: https://imgur.com/dRkzh1w

3 - android: https://imgur.com/8U3HhdP

e a mensagen esta no dont pad: http://dontpad.com/xP38ahZZ

Opa, tem alguma coisa de errado então. Porque o comando 2 deveria ser reconhecido. Se o npm install não está sendo reconhecido provavelmente falta instalar o node na máquina

O erro exibido, inclusive, aponta a falta de uma dependencia do node:

"Unable to resolve module `@babel/runtime/helpers/interopRequireDefault` from `C:\\Users\\rafael.scharf\\Documents\\curso\\REACT\\InstaluraMobile\\index.js`

Qual versão do node você tem instalado?

A versão 10.11.0

imagem do cmd: https://imgur.com/LbqFYGg

e do npm?

npm --v

Versão 6.4.1

https://imgur.com/0Ymaf7T

solução!

Tenta adicionar a biblioteca que está faltando:

npm add @babel/runtime

Vou instalar e testar!

FUNCIONOU! muito obrigado!