Module not found: Can't resolve 'react' - reactjs

I'm trying to connect my Redux store to my React project, but I keep getting this error:
../node_modules/react-redux/es/components/Provider.js Module not
found: Can't resolve 'react' in
'C:\Users.\Documents..\node_modules\react-redux\es\components'
I've installed both react-redux and redux (I believe react-redux has some dependencies on redux)
import { Provider} from 'react-redux';
This is what is giving the error.
Any suggestions on what I could do?

This could be caused by your node_modules
At the first delete your node_modules, package-lock.json, yarn.lock then install all dependencies again
like
rm -rf node_modules
rm -rf package-lock.json
rm -rf yarn.lock
then run
npm install

Please import react at top
import React from 'react'

I faced this issue and it seems you installed react-redux first and redux later.
I assume, react-redux is having some dependencies on redux, which might have created this error. So, recommending you to delete the package-lock.json , run npm install and then npm start.
Let me know if this works!
Thanks

I had same issue, Just run npm audit fix to fix the error

Related

How do I fix missing module error module "./launchEditor" in react code?

I tried to re install react package but still did not fix it
Error: Cannot find module './launchEditor'
Doing a "fresh" install will work with Yarn or npm:
rm -rf node_modules package-lock.json
npm install

Can't resolve 'react-dom' in /ButtonBase'

I'm trying to run a React project created in Mac, I had not this problem neither in Windows or Mac, but I'm facing the following errors when I try to run (npm start) in Ubuntu:
./node_modules/#material-ui/core/esm/ButtonBase/ButtonBase.js
Module not found: Can't resolve 'react-dom' in '/node_modules/#material-ui/core/esm/ButtonBase'
I tried to delete node_modules and ran npm install again, but the problem persists.
Can someone help me with this?
Just install react and react-dom
npm i react react-dom

Cannot find module 'react-dom/test-utils' from 'act-compat.js'

I cannot seem to resolve why I'm receiving this error: Here are my configs:
lang-js
react - 15.3.1
react-dom - 15.3.1
react-testing-library - 6.0.0
jest - 23.6.0
lang-js
import React from 'react';
import { render, fireEvent, cleanup } from 'react-testing-library';
afterEach(cleanup);
test('loads and displays ', async() => {
})
I commented on an open GH issue on the react-testing-library page. Thanks in advance
This may have happened if something got modified or deleted in your react-dom dependency package.
Using yarn
You can verify that already installed files in node_modules did not get removed, reinstalling any missing files by using:
npm install --check-files
That should help you restore react-dom to what it should be.
If that doesn't work, you can always try to completely remove and reinstall all of your packages. From your project root folder, try:
rm -rf node_modules
yarn install
Using npm
First, you can try just to install react-dom again. That might solve your problem:
npm install react-dom
If that doesn't work, then you can try to reinstall all of your packages to get a fresh copy.
From your project root folder, try:
rm -rf node_modules
npm install

Why do I encounter: "TypeError: t(...).isPlaceholder is not a function" when "import './bootstrap/dist/css/bootstrap.min.css'"

I installed bootstrap via npm install already and i tried to import it to my App.js file:
import './bootstrap/dist/css/bootstrap.min.css'
But then the app return this on the browser:
TypeError: t(...).isPlaceholder is not a function
Could someone please explain why and how to fix?
Thank you
For me, I saw these errors when I bumped #babel dependencies a few minor versions (several packages and plugins).
What helped was removing the node_modules directory and then installing all the packages again.
Remove node_modules: rm -rf ./node_modules
Install packages yarn or npm i
Run your project again
I just encountered this error.
To fix it, make sure you're not mixing up your package managers. I was using yarn, but then used npm because that's what we use at work.
you should add or install your modules using the same package manager
For me it works with a standard create-react-app structure via:
import '../node_modules/bootstrap/dist/css/bootstrap.min.css';
For us, it's a yarn bug related to using yarn link with a messy lockfile. The solution was to use yarn-deduplicate.
Prior to finding that fix, my workaround was
yarn link other-repo from main-repo
yarn install from main-repo
yarn install --check-files from other-repo
Which can be done using an alias

After running npm i --save react-router-dom i am getting error

I am getting the error shown below after running the react-router-dom command
how to fix this?
./node_modules/create-react-context/lib/implementation.js Module not found: Can't resolve 'react' in 'C:\xampp\htdocs\learn-router\node_modules\create-react-context\lib'
you have to install react first before installing react-router-dom package,
try this:
rm -rf node_modules
npm i react react-router-dom --save
Add react-router-dom directly to dependencies list in package.json file.
"react-router-dom": "^4.3.1",
then run below command in your project root directory.
npm install

Resources