React Native: Under what circumstances do you have to manually add dependencies of your dependencies? - reactjs

I have the component react-native-modal-datetime-picker in my React Native project. It's throwing the following error:
error: bundling failed: Error: Unable to resolve module '#react-native-community/datetimepicker' from 'node_modules/react-native-modal-datetime-picker/src/DateTimePickerModal.android.js: #react-native-community/datetimepicker could not be found within the project.
It seems that there's a reference in the react-native-modal-datetime-picker module to the #react-native-community/datetimepicker module. I've never run into a scenario before where I had to manually add a dependency of another dependency. Does anyone have any insight on why this is happening?

see the github
you need to run this:
expo install react-native-modal-datetime-picker #react-native-community/datetimepicker

I encountered this same problem and I found that the autolinking wasn't done so I had to run the command
npx react-native link #react-native-community/datetimepicker

‘ #react-native-community/datetimepicker’ is declared as a peer dependency to ‘ react-native-modal-datetime-picker’. Peer dependencies must be installed alongside the original package.

In dependencies, there should be node in case node is not there install npm i node
and try installing date picker again.

Related

React Module not found

I have installed an npm package on my react application but everytime I try to compile I get this error:
Module not found: Error: Can't resolve 'serialport' in 'C:\Users\Username\Desktop\ProjectGroup\c-test\src'
I have checked the node_modules folder and it is in fact in that folder.
i have also tried to install it again but it still throws the same error.
How would I go about fixing this?
As shown in comments, you installed only the types which are usefull for TypeScript.
Run npm i serialport

Module not found: Error: Can't resolve 'util' in `node_modules/aws-sdk/lib` using React.JS

I am following this tutorial for using DynamoDB with React.JS but I get an error that the aws-sdk library can't resolve util.
It is a node package so I shouldn't actually change its code.
I found an answer when using it for Angular here. It also works fine for React.js.
Just install the util package: yarn add util.
The aws-sdk package should have this included in its package file as a dependency.

create-react-app error while using yarn 3

I'm using yarn 3.2.0(latest) and node 17.6.0(latest)
As instructed in CRA documentation I ran yarn create react-app myapp. It completed installation and was able to start the app using yarn start. However after making changes to the App , I always get the following error
ERROR
Failed to load config "react-app" to extend from.
Referenced from: D:\myapp\package.json
If I install any packages, I get module not found error like below
ERROR in ./src/App.js 6:0-39
Module not found: Error: Can't resolve 'styled-components' in 'D:\myapp\src'
Anyone know what's going on?
I had a similar issue. And found that the reason why this was happening to me was due to my Antivirus. Try disabling your antivirus on windows if you have one and re-create your project and if that fixes your issue.

Can't npm start my React project with eslint dependencies

I installed eslint in my react project to fix all the eslint errors. I fixed all the errors, however, I can't npm start the project. When I do that, I get this error, and some steps to uninstall all the eslint dependencies. I want to run the project with eslint dependencies.
Please let me know how to do this?
Error Message:
There might be a problem with the project dependency tree. It is
likely not a bug in Create React App, but something you need to fix
locally.
The react-scripts package provided by Create React App requires a
dependency:
"eslint": "^7.11.0"
Don't try to install it manually: your package manager does it
automatically. However, a different version of eslint was detected
higher up in the tree:
My guess would be that you installed eslint#v8 and since create-react-app doesn't support it yet (reference) it causes this error.
Downgrading to eslint v7 should fix it.
Create react app already comes bundled with eslint and by installing it in the project dependencies, you are in effect try to load in conflicting versions, you shouldn't need eslint inside of your own package.json.
HOWEVER
If you want to override eslint and start customising your react install you are more than welcome to eject (npm run eject), but bear in mind that ejecting your application will mean you will need to maintain dependencies going forwards.
You can read more about ejecting here - https://create-react-app.dev/docs/available-scripts/

Unable to resolve a dependency in react native maps?

Problem:
I have create react native application. There I am using react-native-maps. When bundle is building it laves this error on the console.
Unable to resolve "./lib/components/MapHeatmap.js" from
"node_modules\react-native-maps\index.js"
I look for a solution but I was unable to do so. And I have not any clue for what should do for this error.Thank you
i had the same error just now, try sudo npm uninstall react-native-maps and install it again with expo comand (if you are using expo).
I was also facing the same issue in react native (expo)
For me clearing the cache worked...
just type this command
expo start -c
in cli project run this command on your project
npm cache clean --force
then reinstall the node module ......
then npm install

Resources