React Native bundle error : Module `scheduler` does not exist in the Haste module map - node.js

In my react native project if I run the bundling command, It fails with the mentioned error.
Command:
`sudo react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/`
Error:
error Unable to resolve module 'scheduler' from '/home/buddhi/Buddhi/my-dev-environment/html/react-apps/mobile-64/node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-prod.js': Module 'scheduler' 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-*'.. Run CLI with --verbose flag for more details.
Versions:
"react": "16.8.3"
"react-native": "0.59.0"
"npm": 6.9.0
"node": 10.16.0
When I run the same command with react-native 0.57.2 is runs perfectly. (Note that I need to use react native version 0.59.0 to get the android x64 architecture support for the application)
I have tried the mentioned steps in the error.
I tried by deleting /node_modules and npm install again numerous times.
Tried after npm start --reset-cache.
Still the issue is there.
The change as I can see is that in react-native version 0.59.0 there is the line var scheduler = require("scheduler"), in the file ReactNativeRenderer-prod.js as mentioned in the error. But in react-native version 0.57.2 it is not used.
I'm pretty sure that this is caused by npm, not an issue of the react-native versions. Is it?
Can't figure out why it is not in the mentioned Haste Module Map, and what exactly is the Haste Module Map? I couldn't find enough information to support the issue.
Any help appreciated. Ask for additional information.

If you are using expo, then make sure that your expo and react-native versions are the following:
"expo": "^35.0.0",
"react": "16.8.3",
"react-native": "https://github.com/expo/react-native/archive/sdk-35.0.0.tar.gz",
Only this combination worked for me.

Related

why I can't change Typescript version even though I have downgraded the version

so previously, I installed Typecript on my new macbook by running this command
sudo npm install typescript -g
and I got Typescript version 4.7.4. and then I want to deploy the function using this command
firebase deploy
unfortunately, there is a warning like this
WARNING: You are currently running a version of TypeScript which is
not officially supported by #typescript-eslint/typescript-estree.
You may find that it works just fine, or you may not.
SUPPORTED TYPESCRIPT VERSIONS: >=3.3.1 <4.1.0
YOUR TYPESCRIPT VERSION: 4.7.4
Please only submit bug reports when using the officially supported
version.
and then I downgrade to version 4.0.7, but unfortunately that warning still exist, it seems my app is still on v4.7.4 (cached ? ) I am sure I have changed the typescript version on package.json and I also check via terminal like the image below
but why my node app still have version v.4.7.4 ? not v.4.0.7 ? what should I do?
fiuhhh....after 2 days, I finally find the solution
I have to change the dependencies and also the devDependencies, especially these dependencies in the package.json
"dependencies": {
"firebase-admin": "^10.0.2",
"firebase-functions": "^3.18.0",
},
"devDependencies": {
"#typescript-eslint/eslint-plugin": "^5.12.0",
"#typescript-eslint/parser": "^5.12.0",
"eslint": "^8.9.0",
"eslint-config-google": "^0.14.0",
"eslint-plugin-import": "^2.25.4",
"typescript": "^4.5.4" // <-- watch this version
},
the problem is ....it seems to me that these dependencies is tightly coupled. it can easily break if it doesn't match. so my solution is to create new project just to copy and paste those dependencies combination above with the latest version recommended by firebase. watch this video if you are confused how to initialize cloud function project
first, Update your firebase tools to the latest version using this command
sudo npm install -g firebase-tools
and change to your directory and init the project
cd desktop
mkdir forCopyPasteDependenciesOnly
firebase init
select cloud function and typescript. and then you copy those dependencies above and paste it on your problematic project
in my case, I also change the typescript globally using the recommended typescript version from the project package.json that you just initialize (4.5.4, not 4.0.7 or 4.7.4 in my case )
sudo npm uninstall -g typescript
sudo npm install -g typescript#4.5.4
and then, in your problematic project, delete your node-modules folder
and delete your package-lock.json. and finally run these 2 commands below
npm cache clean –force
npm install
and when you run firebase deploy you may see errors, but luckily it just error from eslint you just update, you can solve it easily.
I hope it helps
You installed typescript as globally on your system but you changed just in your package.json.
First you should type this npm uninstall -g typescript.
Then npm install -g typescript#your version.
After that you can uninstall your local tsc on your project.

React 18.1.0 Dependency Tree Errors- can't resolve dependency tree

I am currently having trouble solving dependency tree error with React 18. Initially, I couldn't start a new react project with npx-create-react-app my-app (a template was not provided). I fixed that and can now start a new project, but I have two other react apps that I cannot get to start up.
The first one is a portfolio react template that I downloaded. I opened it up and ran npm start in the terminal with no luck (attached is the dependency tree error message).
These are the steps I took to try to fix it:
I deleted all react and node folders that were dowloaded on my Mac (outside of the directory).
Ran npm install --save --legacy-peer-deps
Ran rm -rf node_modules
Ran npm cach clean --force
I removed package.lock.json
I changed these scripts in package.json to updated versions
nodemon: 2.0.16
react: 18.1.0
react-scripts: 5.0.1
React-dom: 18.1.0
When I then run npm start I get the dependency errors. I would appreciate any help and advice! Thanks so much![!dependency errors]

Module `scheduler` does not exist in the Haste module map

I am trying to run existing expo project.
I've cloned it and ran yarn and then expo start. and got this error:
Unable to resolve module scheduler from /path-to-project/node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-prod.js: Module scheduler does not exist in the Haste module map
This might be related to https://github.com/facebook/react-native/issues/4968
Tried to solve it by:
Clear watchman watches: watchman watch-del-all.
Delete the node_modules folder: rm -rf node_modules && npm install.
Reset Metro Bundler cache: rm -rf /tmp/metro-bundler-cache-* or npm start -- --reset-cache.
Remove haste cache: rm -rf /tmp/haste-map-react-native-packager-*.
deleted and cloned project again multiple times
deleted node_modules and reinstalled
reinstalled watchman, npm and updated brew.
Installed latest version of schedule package (0.5.0) instead of (0.4.0)
Clues:
When trying to run iOS simulator, the budling gets stuck at %99
Building JavaScript bundle [================================= ] 99%
after that:
Failed building JavaScript bundle.
Solved by adding those versions into my project.
"expo": "^35.0.0",
"react": "16.8.3",
"react-dom": "16.8.3",
"react-native": "https://github.com/expo/react-native/archive/sdk-35.0.0.tar.gz",
"react-native-web": "^0.11.7"
However, I got other issues by updating expo version.

Unable to resolve module `react/lib/ReactComponentTreeHook`

I'm attempting to upgrade React Native and I'm running into the following:
error: bundling: UnableToResolveError: Unable to resolve module `react/lib/ReactComponentTreeHook` from `/Users/anthony/dev/apptova-react/node_modules/react-native/Libraries/Performance/Systrace.js`: Module does not exist in the module map or in these directories:
/Users/anthony/dev/apptova-react/node_modules/react-native/node_modules/react/lib
, /Users/anthony/dev/apptova-react/node_modules/react/lib
I'm so confused. I can't find any library named ReactComponentTreeHook in node_modules, anywhere.
I've tried removing the node_modules folder and reinstalling, nada. I've also cleared watchman watches and reset the packager cache.
EDIT: I kept running into issues that seemed to stem from react-native-maps so I so I reset back to a working stable version, uninstalled react-native-maps, and ran react-native-git-upgrade (again).
Now I'm getting:
error: bundling: UnableToResolveError: Unable to resolve module `react/lib/ReactDebugCurrentFrame` from `/Users/anthony/dev/apptova-react/node_modules/react-native/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactCompositeComponent.js`: Module does not exist in the module map or in these directories:
/Users/anthony/dev/apptova-react/node_modules/react-native/node_modules/react/lib
, /Users/anthony/dev/apptova-react/node_modules/react/lib
I'm just trying to latest, my package.json dependencies are simple so I don't think its conflicts with a third-party code base:
"dependencies": {
"react": "15.4.1",
"react-native": "^0.43.1",
"react-native-drawer": "^2.3.0"
},
"devDependencies": {
"babel-jest": "18.0.0",
"babel-plugin-transform-flow-strip-types": "^6.21.0",
"babel-preset-react-native": "1.9.1",
"deepmerge": "^1.3.2",
"flow-bin": "^0.37.4",
"jest": "18.0.0",
"react-test-renderer": "15.4.1"
},
Again, went throught the process of clearing watchman watches, node modules, reseting package manager and still get this error.
EDIT 2: After spending two solid days of trying to get this working I created a new blank project and migrated my code over.
Make sure version in your package.json file is the version you want.
For example, "react-native: ^0.43.3" is not same as "react-native: 0.43.3".
Clean up and re-install everything.
If the error still there, then try to install react-native-git-upgrade
$ npm install -g react-native-git-upgrade
and then run
$ react-native-git-upgrade x.y.z(version you want to upgrade to)
for me it works.
If your version is too old, then you should follow the old version document to upgrade.
This could also happen if you don't have the correct version of react required by the version of react-native. If this is the case, you would get a warning like this when you run npm install.
npm WARN react-native#0.43.4 requires a peer of react#16.0.0-alpha.6 but none was installed.
To fix this problem, stop the react packager and upgrade the version of react by running the following command
npm install -save react#16.0.0-alpha.6
Now, re-run the app and hopefully the issue would go away.
I think recently many of the modules under react/lib were moved to react-dom/lib, which is why the packager can't find some modules
I followed following steps and it's working
• Deleted node_modules folder
• Replaced ^16.0.0-alpha.6 with "react": "16.0.0-alpha.3"
• npm install
• react-native run-android

Webpack Cannot find module ./lib/api/node.js # multi main

I removed all node_modules from my project and installed it again.
Before removing them everything was working fine. Now I'm getting an error at the end of webpack build :
After it happened I:
uninstalled webpack completely with -g option, installed it locally with npm install in my project.
uninstalled nodejs completely both with brew and manually removing all suspected files related to node or npm
installed nodejs with brew again.
Unfortunatelly I'm still getting the same error.
When I try to run the project with npm run dev where dev in package.json file is: "dev": "webpack-dev-server --progress --colors"
I'm getting the following error :
where ./app/index.jsx is the entry file for my project
Before all was fine, the directory structure was indentical, I haven't touched anything in the project apart from removing node_modules and installing it all again.
webpack version: 1.13.2 node version: 7.0.0 webpack-dev-server
version: 1.16.2
Any ideas greatly appreciated.
Thanks
Answering my own question just in case someone encounters the same issue:
I did the following steps:
remove webpack and webpack-dev-server from the package.json file
remove node_modules folder
run npm install
install both again (latest versions) npm install --save-dev webpack webpack-dev-server
After installing them the versions are as follows:
webpack: 1.13.3 (was 1.13.2 before) | webpack-dev-server: 1.16.2
Done!
1.remove foldernode_modules
2.run npm install
thx! my problems is solved by these two steps only !

Resources