I don't understand why I have this problem when I launch the emulator.
warning: the transform cache was reset.
Loading dependency graph, done.
error: bundling failed: Error: Unable to resolve module `react` from `/Users/myname/Sites/Project/App.js`: Module `react` does not exist in the Haste module map
This might be related to https://github.com/facebook/react-native/issues/4968
To resolve try the following:
1. Clear watchman watches: `watchman watch-del-all`.
2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.
3. Reset Metro Bundler cache: `rm -rf /tmp/metro-bundler-cache-*` or `npm start -- --reset-cache`.
4. Remove haste cache: `rm -rf /tmp/haste-map-react-native-packager-*`.
I start the server with npm start -- --reset-cache command but it doesn't work. And also I tried to follow the above instruction.
How can I do?
I don't believe that it is a code problem, I update my Android Studio and install a component (react native elements) and now it doesn't work anymore.
Some help?
I solved by installing in the application folder:
npm install react
Related
I'm keep getting this error whenever I try to install any npm package on my windows 10 for android. It shows the package added in android studio and node_modules as well. However when i import the npm package in JS file and run the project the error comes up. With the below instructions :
If you are sure the module exists, try these steps:
Clear watchman watches: watchman watch-del-all
Delete node_modules: rm -rf node_modules and run yarn install
Reset Metro's cache: yarn start --reset-cache
Remove the cache: rm -rf /tmp/metro-*
Does anyone knows what i'm doing wrong? I'm using react-native 0.63.2
It means the metro bundler does not know there is a new package installed. In that case, turn off the metro bundler and follow the steps you listed above and then npx react-native run-android. Those steps clear the cache and help metro find the new package that was installed.
Check in any of the files you were working on recently and be sure you are not mistakenly importing XXXXX somewhere, in my case it was process as shown in the image above. Most times it happens when you invoke a function or method within your module
Has anyone experience this error with expo, when running react-native run-android?
error: bundling failed: Error: Unable to resolve module `./Linking/Linking` from `node_modules/expo/build/ExpoLazy.js`:
None of these files exist:
* node_modules/expo/build/Linking/Linking(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)
* node_modules/expo/build/Linking/Linking/index(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)
"expo": "^37.0.9",
Just ran into this issue, downgrade to 37.0.8 (no caret) and do an npm i. Looks like they released 37.0.9 yesterday and it has an issue.
What worked for me:
1) In package.json change to "expo": "37.0.8"
2) Delete your node_modules
3) installl packages npm i
4) clean cache in expo expo r -c
Now it started to work again. Couldn't find the last step in previous comments.
This is an Internal bug of react-native. You don't have much of a choice, as user3916570 consider downgrading.
For now, downgrading Expo to 37.0.8 fixed this. To downgrade, in your package.json, change your Expo dependency to:
"expo": "37.0.8",
Then remove your node_modules and reinstall everything:
rm -rf node_modules
npm i
It's not an expo version problem only, you should also check the global expo-cli version and probably node as well.
Run:
$ npm install -g expo-cli --force
$ rm -rf node_modules/
$ rm -rf package-lock.json
# (in my case mac '$ brew upgrade node && npm install -g npm')
$ npm install
$ npm run
react-native: 0.57.0
yarn : 1.9.4
nodejs: 9.10.1
react-native run-android give me this error:
[android, dev] ..\..\../index.js ░░░░░░░░░░░░░░░░ 0.0% (0/1)::ffff:127.0.0.1 - - [14/Sep/2018:07:12:00 +0000] "GET /index.delta?platform=android&dev=true&minify=false HTTP/1.1" 500 - "-" "okhttp/3.10.0"
error: bundling failed: ReferenceError: SHA-1 for file c:\wamp64\www\React\hello1\index.js is not computed
at DependencyGraph.getSha1 (c:\wamp64\www\React\hello1\node_modules\metro\src\node-haste\DependencyGraph.js:238:119)
at c:\wamp64\www\React\hello1\node_modules\metro\src\Bundler.js:168:56
at Generator.next (<anonymous>)
at step (c:\wamp64\www\React\hello1\node_modules\metro\src\Bundler.js:11:657)
at c:\wamp64\www\React\hello1\node_modules\metro\src\Bundler.js:11:817
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:118:7)
That looks like an issue related to metro.
Try to close console and in the project folder run:
rm -rf $TMPDIR/react-* && rm -rf $TMPDIR/metro-* && rm -rf $TMPDIR/haste-* && watchman watch-del-all && rm -rf node_modules/ && npm install && npm start -- --reset-cache
then run
react-native run-android
For windows cleaning cache should be something like this:
del %appdata%\Temp\react-* & del %appdata%\Temp\metro-* & del %appdata%\Temp\haste-* & del node_modules & npm install & watchman watch-del-all & npm start -- --reset-cache
(I haven't tried it on windows, probably for windows best option to remove node_modules would be to install rimraf)
If it still doesn't work check package.json and .babelrc. You should have something like this:
"metro-react-native-babel-preset": "^0.45.0", and .babelrc configuration:
{
"presets": ["module:metro-react-native-babel-preset"]
}
I used
npm install
npm audit fix
and then on different consoles
npx react-native start
i just try:
watchman watch-del-all && rm -rf node_modules/ && yarn install && yarn run dev
and in my case, i uninstall and reinstall my app on emulator, then it works
mac users: open terminal and follow:
1.npm uninstall -g react-native-cli
2.cd
3.cd .npm-global
4.cd bin
5.rm -rf react-native
6.npm install -g react-native-cli
Notice: if you are a Windows user go to your user folder and delete "react-native" folder instead of steps 2..5
I am attempting to learn React Native so I went ahead and followed all the steps in the Getting Started guide at the official documentation site. I have some experience with React so i wanted to expand on it.
I did wade in around 6 months ago for a simple 'hello world' app and everything worked fine for me on both the Android emulator and the IoS simulator. Did test on my device as well and had no issues. Since i got busy with other work i did not get back to it until now.
The error i get when i attempt the react-native run-android command:
Metro Bundler ready.
Loading dependency graph, done.
error: bundling failed: Error: Unable to resolve module `react-native` from `/Users/arunmenon/Sites/reactnative/website/index.js`: Module `react-native` does not exist in the Haste module map or in these directories:
/Users/arunmenon/Sites/reactnative/website/node_modules
This might be related to https://github.com/facebook/react-native/issues/4968
To resolve try the following:
1. Clear watchman watches: `watchman watch-del-all`.
2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.
3. Reset Metro Bundler cache: `rm -rf /tmp/metro-bundler-cache-*` or `npm start -- --reset-cache`. 4. Remove haste cache: `rm -rf /tmp/haste-map-react-native-packager-*`.
at ModuleResolver.resolveDependency (/Users/arunmenon/Sites/reactnative/website/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:161:1460)
at ResolutionRequest.resolveDependency (/Users/arunmenon/Sites/reactnative/website/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:91:16)
at DependencyGraph.resolveDependency (/Users/arunmenon/Sites/reactnative/website/node_modules/metro/src/node-haste/DependencyGraph.js:272:4579)
at dependencies.map.relativePath (/Users/arunmenon/Sites/reactnative/website/node_modules/metro/src/DeltaBundler/traverseDependencies.js:376:19)
at Array.map (<anonymous>)
at resolveDependencies (/Users/arunmenon/Sites/reactnative/website/node_modules/metro/src/DeltaBundler/traverseDependencies.js:374:16)
at /Users/arunmenon/Sites/reactnative/website/node_modules/metro/src/DeltaBundler/traverseDependencies.js:212:33
at Generator.next (<anonymous>)
at step (/Users/arunmenon/Sites/reactnative/website/node_modules/metro/src/DeltaBundler/traverseDependencies.js:297:313)
at /Users/arunmenon/Sites/reactnative/website/node_modules/metro/src/DeltaBundler/traverseDependencies.js:297:473
BUNDLE [android, dev] ./index.js ░░░░░░░░░░░░░░░░ 0.0% (0/1), failed.
I tried all the suggested steps but the issue still persists. The error:
Error: Unable to resolve module `react-native` from `/Users/arunmenon/Sites/reactnative/website/index.js`:
Module `react-native` does not exist in the Haste module map or in these directories:
/Users/arunmenon/Sites/reactnative/website/node_modules
suggests that it looks like somehow there is some issue with picking up the path from node_modules. The first line in index.js is import { AppRegistry } from 'react-native'; and thats where the error is thrown.
The paths mentioned are valid and i do have react-native installed in the node_modules directory in the path.
I am developing on a Mac and the targeted device currently is Android. I am going the react-native CLI command route and not the create-react-native-app route.
I have Android Studio 3.1.3 (updated last night), Node 8.11.2, NPM 6.1.0, Watchman 4.9.0 (installed via Homebrew), Java JDK 1.8.0_144.
I followed the getting started guid to a T. Since i got t working earlier - around 6 months ago - i wonder why i get this now. I have the same Android Studio version as then(i updated Android Studio yesterday to rule out issues with having an older version. I get the same error with the new version as well) The difference between then and now:
React-native library version has obviously been bumped up from then
Java version, i recently updated it to the latest
Node and NPM versions are newer
Watchman also i think since Homebrew did update it
Everything else is the same. I tried a couple of fresh install as well - starting over from the beginning i.e but it didnt work.
My package.json:
{
"name": "website",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "16.3.1",
"react-native": "0.55.4"
},
"devDependencies": {
"babel-jest": "23.2.0",
"babel-preset-react-native": "4.0.0",
"jest": "23.2.0",
"react-test-renderer": "16.3.1"
},
"jest": {
"preset": "react-native"
}
}
Please remove all react-native specific folders from "%appdata%\Temp" and then try below commands:
cd android
gradlew clean
cd.. and remove the node_modules folder
npm cache clean --force
npm install
npm start -- --reset-cache
react-native run-android
The above didn't work for me on Mac OSX, but this one did: after npm install, run these:
# Clean cache
rm -rf $TMPDIR/react-*; rm -rf $TMPDIR/haste-*; rm -rf $TMPDIR/metro-*; watchman watch-del-all
# Start React-Native directly
react-native start --reset-cache
# Now run android/iOS in another tab
react-native run-android
Original post: https://github.com/facebook/react-native/issues/21490#issuecomment-427240356
In my case problem was newly installed package. so try with uninstall the npm package which you newly installed. npm uninstall --save
Getting error "Config.h file not found, lexical or preprocessor error."
I am running app in the device from the xcode project.
I have google and found many solutions but haven't worked, I tried this
https://github.com/facebook/react-native/issues/14382
And when I try to run in the iOS simulator getting this error
https://github.com/facebook/react-native/issues/10401
Tried to follow the above url but didn't work.
Please let me know how to solve the issue.
Thanks
try it
Open Terminal, go to your project’s root folder and do:
cd node_modules/react-native/third-party/glog-0.3.4/
Run the configure script:
./configure
Open Xcode and try to run your app.
Xcode 10
"react-native": "0.57.5"
cd ./node_modules/react-native && scripts/ios-install-third-party.sh && cd third-party && cd $(ls | grep 'glog' | awk '{print $1}') && ./configure
I faced the same issue and it's fixed by these commands:-
yarn
rm -rf node_modules/
yarn cache clean
yarn install
npm
rm -rf node_modules/
npm cache clean
npm i
For me:
# rm -rf node_modules
# npm cache verify (Because I'm using npm version 5.0.3)
# npm install
Xcode Clean
Xcode Run
If that doesn't work,
In the Terminal, navigate to the react-native/third-party/glog folder inside node_modules
(for me, this was cd node_modules/react-native/third-party/glog-0.3.4)
Once actively in this folder,
#run ../../scripts/ios-configure-glog.sh
Glog is configured and the required config.h header file is created for Xcode to find
Just go on the config.h file, click on the right panel and add the file to the app target by checking the right case. Clean and compile again.
Remove the third-party folder in your node_modules/react-native folder.