issue installing react icons with npm - reactjs

I'm following a react tutorial on lynda.com. I'm trying to install react icons through npm to my react project. I'm getting some weird warnings in the command line that I don't understand. Here's the result in the tutorial vs. my result:
This is the tutorial's result the terminal.
This is my result in the terminal:
Last login: Sat Aug 11 11:54:48 on ttys005
dashiell-bark-husss-macbook-pro-2:bulletin-board dashiellbark-huss$ npm install --save react-icons
npm WARN rm not removing /Users/dashiellbark-huss/Downloads/Ex_Files_Learning_Reactjs/Exercise Files/Ch03/03_02/start/bulletin-board/node_modules/.bin/jest as it wasn't installed by /Users/dashiellbark-huss/Downloads/Ex_Files_Learning_Reactjs/Exercise Files/Ch03/03_02/start/bulletin-board/node_modules/jest
npm WARN rm not removing /Users/dashiellbark-huss/Downloads/Ex_Files_Learning_Reactjs/Exercise Files/Ch03/03_02/start/bulletin-board/node_modules/.bin/uglifyjs as it wasn't installed by /Users/dashiellbark-huss/Downloads/Ex_Files_Learning_Reactjs/Exercise Files/Ch03/03_02/start/bulletin-board/node_modules/uglify-js
npm WARN rm not removing /Users/dashiellbark-huss/Downloads/Ex_Files_Learning_Reactjs/Exercise Files/Ch03/03_02/start/bulletin-board/node_modules/html-minifier/node_modules/.bin/uglifyjs as it wasn't installed by /Users/dashiellbark-huss/Downloads/Ex_Files_Learning_Reactjs/Exercise Files/Ch03/03_02/start/bulletin-board/node_modules/html-minifier/node_modules/uglify-js
npm WARN rm not removing /Users/dashiellbark-huss/Downloads/Ex_Files_Learning_Reactjs/Exercise Files/Ch03/03_02/start/bulletin-board/node_modules/fsevents/node_modules/.bin/node-pre-gyp as it wasn't installed by /Users/dashiellbark-huss/Downloads/Ex_Files_Learning_Reactjs/Exercise Files/Ch03/03_02/start/bulletin-board/node_modules/fsevents/node_modules/node-pre-gyp
npm WARN rm not removing /Users/dashiellbark-huss/Downloads/Ex_Files_Learning_Reactjs/Exercise Files/Ch03/03_02/start/bulletin-board/node_modules/.bin/esparse as it wasn't installed by /Users/dashiellbark-huss/Downloads/Ex_Files_Learning_Reactjs/Exercise Files/Ch03/03_02/start/bulletin-board/node_modules/esprima
npm WARN rm not removing /Users/dashiellbark-huss/Downloads/Ex_Files_Learning_Reactjs/Exercise Files/Ch03/03_02/start/bulletin-board/node_modules/.bin/esvalidate as it wasn't installed by /Users/dashiellbark-huss/Downloads/Ex_Files_Learning_Reactjs/Exercise Files/Ch03/03_02/start/bulletin-board/node_modules/esprima
npm WARN rm not removing /Users/dashiellbark-huss/Downloads/Ex_Files_Learning_Reactjs/Exercise Files/Ch03/03_02/start/bulletin-board/node_modules/espree/node_modules/.bin/acorn as it wasn't installed by /Users/dashiellbark-huss/Downloads/Ex_Files_Learning_Reactjs/Exercise Files/Ch03/03_02/start/bulletin-board/node_modules/espree/node_modules/acorn
npm WARN rm not removing /Users/dashiellbark-huss/Downloads/Ex_Files_Learning_Reactjs/Exercise Files/Ch03/03_02/start/bulletin-board/node_modules/.bin/browserslist as it wasn't installed by /Users/dashiellbark-huss/Downloads/Ex_Files_Learning_Reactjs/Exercise Files/Ch03/03_02/start/bulletin-board/node_modules/browserslist
npm WARN rm not removing /Users/dashiellbark-huss/Downloads/Ex_Files_Learning_Reactjs/Exercise Files/Ch03/03_02/start/bulletin-board/node_modules/autoprefixer/node_modules/.bin/browserslist as it wasn't installed by /Users/dashiellbark-huss/Downloads/Ex_Files_Learning_Reactjs/Exercise Files/Ch03/03_02/start/bulletin-board/node_modules/autoprefixer/node_modules/browserslist
npm notice created a lockfile as package-lock.json. You should commit this file.
+ react-icons#3.0.5
added 1 package and removed 1311 packages in 10.061s
dashiell-bark-husss-macbook-pro-2:bulletin-board dashiellbark-huss$
Here's a screen shot which may be easier to view:
Now, when I try to use icons, I get this error:
./src/Note.js
Module not found: Can't resolve 'react-icons/lib/fa/pencil' in '/Users/dashiellbark-huss/Downloads/Ex_Files_Learning_Reactjs/Exercise Files/Ch03/03_02/start/bulletin-board/src'
I'm guessing this error is related to what the command line showed me when I tried to install the icons.
I'm very new to react and npm, so I'm looking for some guidance on why this isn't acting as expected and how to fix this?
Update:
I'm now getting a different error:
Module build failed: Error: ENOENT: no such file or directory, open '/Users/dashiellbark-huss/Downloads/Ex_Files_Learning_Reactjs/Exercise Files/Ch03/03_02/start/bulletin-board/node_modules/react/index.js'
I ran npm outdated in the terminal and found some weird results: it looks like npm thinks react, react-dom, and react-script are missing. Honestly this is a bit over my head and I don't know what it means but that looks wrong.
dashiell-bark-husss-macbook-pro-2:bulletin-board dashiellbark-huss$ npm outdated
Package Current Wanted Latest Location
react MISSING 16.4.2 16.4.2 bulletin-board
react-dom MISSING 16.4.2 16.4.2 bulletin-board
react-scripts MISSING 1.1.4 1.1.4 bulletin-board
I went into my package.json file and saw that those all have a caret symbol infront of them:
"react": "^16.4.2",
"react-dom": "^16.4.2",
"react-icons": "^3.0.5"
Full package.json file contents:
{
"name": "bulletin-board",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.4.2",
"react-dom": "^16.4.2",
"react-icons": "^3.0.5",
"react-scripts": "1.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
2nd Update: An per user Win's suggestion I ran npm install. This changed some things.
This was the result in the command line:
dashiell-bark-husss-macbook-pro-2:bulletin-board dashiellbark-huss$ npm install
npm WARN deprecated browserslist#2.11.3: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm WARN deprecated browserslist#1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm WARN deprecated istanbul-lib-hook#1.2.1: 1.2.0 should have been a major version bump
> fsevents#1.2.4 install /Users/dashiellbark-huss/Downloads/Ex_Files_Learning_Reactjs/Exercise Files/Ch03/03_02/start/bulletin-board/node_modules/fsevents
> node install
[fsevents] Success: "/Users/dashiellbark-huss/Downloads/Ex_Files_Learning_Reactjs/Exercise Files/Ch03/03_02/start/bulletin-board/node_modules/fsevents/lib/binding/Release/node-v59-darwin-x64/fse.node" is installed via remote
> uglifyjs-webpack-plugin#0.4.6 postinstall /Users/dashiellbark-huss/Downloads/Ex_Files_Learning_Reactjs/Exercise Files/Ch03/03_02/start/bulletin-board/node_modules/uglifyjs-webpack-plugin
> node lib/post_install.js
npm WARN ajv-keywords#3.2.0 requires a peer of ajv#^6.0.0 but none is installed. You must install peer dependencies yourself.
added 1298 packages and updated 88 packages in 24.848s
Now, If I use the syntax import { FaPencil } from 'react-icons/fa' to import, my page compiles but with these warnings :
./src/Note.js
Line 2: 'FaPencil' is defined but never used no-unused-vars
Line 3: 'FaTrash' is defined but never used no-unused-vars:
But if I use the syntax import FaPencil from 'react-icons/lib/fa/pencil' to import, my page does not compile and I get this error:
./src/Note.js
Module not found: Can't resolve 'react-icons/lib/fa/pencil' in '/Users/dashiellbark-huss/Downloads/Ex_Files_Learning_Reactjs/Exercise Files/Ch03/03_02/start/bulletin-board/src'
Update 3:
After fixing a syntax error, I now get a different error
'react-icons/fa' does not contain an export named 'FaPencil'.
npm version 5.6.0

You're trying to access a paid icon. You will have to use the free pencil icon:
import { FaPencilAlt } from 'react-icons/fa';
and then use it like so
<FaPencilAlt/>
You can find a list of icons you can use here: https://fontawesome.com/icons?d=gallery&q=Pencil
Anything marked as PRO will not be available.

I found it quite difficult to install react-icons as well, a fix for me was to simply uninstall and install node.js again. This worked fine for me.

Related

How do I downgrade react-scripts 5.0.1 to 4.0.3

I'm having the issue that's faced in this question: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema
One of the solutions is to downgrade react-scripts to 4.0.3 and I'm not sure how to do that. Could someone help me?
Could always delete your node_modules directory and change the version in your package.json under dependencies:
"dependencies": {
"react-scripts" :"5.0.1",
}
then run an install. It's better to do a terminal approach when looking to change versions of a package, like:
NPM
uninstall:
npm uninstall react-scripts
install:
npm install --save react-scripts#4.0.3
Yarn
since Yarn is the preferred for Create React App per memory:
uninstall:
yarn remove react-scripts
install:
yarn add react-scripts#4.0.3
You have at least 2 options.
First, in your project folder you run the following command:
npm i react-scripts#4.0.3
Source: https://www.npmjs.com/package/react-scripts/v/4.0.3?activeTab=versions
Second, you open your package.json file in your project and change the version number of react-scripts to 4.0.3
"dependencies": {
"react-scripts" :"4.0.3",
...
}
and run npm i.
This will upgrade or downgrade everything to the version that are stated in your package.json file.

reactjs. Error: Node Sass version 7.0.1 is incompatible with ^4.0.0 [duplicate]

I've created a blank React project, using the command: npx create-react-app on npm v7.0.7 and Node.js v15.0.1
Installed:
React v17.0.1,
node-sass v5.0.0,
Then I tried to import a blank .scss file to the App component:
File App.js
import './App.scss'
function App() {
return (
<div className="App">
App
</div>
);
}
export default App;
It throws an error:
Failed to compile.
./src/App.scss (./node_modules/css-loader/dist/cjs.js??ref--5-oneOf-6-1!./node_modules/postcss-loader/src??postcss!./node_modules/resolve-url-loader??ref--5-oneOf-6-3!./node_modules/s
ass-loader/dist/cjs.js??ref--5-oneOf-6-4!./src/App.scss)
Error: Node Sass version 5.0.0 is incompatible with ^4.0.0.
File package.json
{
"name": "react-17-node-sass-5",
"version": "0.1.0",
"private": true,
"dependencies": {
"#testing-library/jest-dom": "^5.11.5",
"#testing-library/react": "^11.1.0",
"#testing-library/user-event": "^12.1.10",
"node-sass": "^5.0.0",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-scripts": "4.0.0",
"web-vitals": "^0.2.4"
},
...
}
}
TL;DR
npm uninstall node-sass
npm install sass
Or, if using Yarn
yarn remove node-sass
yarn add sass
Edit3: yes, another edit. Moving to sass (dart-sass) is the best solution. Previous one included locking node-sass to version 4.x.x, which is 2 years old and lacks newer SCSS features.
Edit2: sass-loader v10.0.5 fixes it. The problem is you might not be using it as a project dependency, but more as a dependency of your dependencies. CRA uses a fixed version, angular-cli locks to node-sass v4, and so on.
The recommendation for now is: if you're installing just node-sass, check the below workaround (and the note). If you're working on a blank project and you can manage your Webpack configuration (not using CRA or a CLI to scaffold your project), install the latest sass-loader.
Edit: this error comes from sass-loader. There is a semantic versioning mismatch since node-sass #latest is v5.0.0 and sass-loader expects ^4.0.0.
There is an open issue on their repository with an associated fix that needs to be reviewed. Until then, refer to the solution below.
Workaround: don't install node-sass 5.0.0 yet (the major version was just bumped).
Uninstall node-sass
npm uninstall node-sass
Then install the latest version (before 5.0)
npm install node-sass#4.14.1
Note: LibSass (hence node-sass as well) is deprecated and dart-sass is the recommended implementation. You can use sass instead, which is a Node.js distribution of dart-sass compiled to pure JavaScript.
The only one reason why you get some error like that, is because your Node.js version is not compatible with your node-sass version.
So, make sure to checkout the documentation at node-sass.
Or this image below will be help you in deciding what Node.js version can use the node-sass version.
For an example, if you're using Node.js version 12 on your Windows system ("maybe"), then you should have to install the node-sass version 4.12.
npm install node-sass#4.12
Yeah, like that. So now you only need to install the node-sass version recommended by the node-sass team with Node.js version installed on your computer.
Uninstall node-sass:
npm uninstall node-sass
Use sass by:
npm install -g sass
npm install --save-dev sass
node-sass aka LibSass is officially deprecated as of October 26 2020 and instead you should use sass aka Dart Sass.
For npm you could do:
npm uninstall node-sass
npm install sass --save-dev
For yarn do:
yarn remove node-sass
yarn add sass
The best solution for me was uninstalling node-sass.
npm uninstall node-sass
then install sass:
npm install sass
For those using Yarn:
yarn remove node-sass
yarn add sass
If you happen to use CRA with the default Yarn package manager, use the following. It worked for me.
yarn remove node-sass
yarn add node-sass#4.14.1
Using npm,
npm uninstall node-sass
npm install node-sass
change the "react-scripts": "4.0.0" into "react-scripts": "4.0.3" in package.json and save
npm install
npm start
or, using yarn -
yarn remove node-sass
yarn add --dev node-sass
as above
yarn install
yarn start
This is version problem. Install the right dependent version:
npm uninstall node-sass
npm install node-sass#4.14.1
According to the Edit2 of Nicolas Hevia telling that
sass-loader v10.0.5 fixes it
I launched this command:
npm install sass-loader#^10.0.5 node-sass --save-dev
That fixed my issue.
Be aware that I am in a development environment. In other cases, the option --save-dev should be removed.
It worked for me after adding a particular version of the node-sass package (node-sass#4.14.1).
You can just switch to Sass since node-sass is deprecated now anyway.
In your package.json file:
"node-sass": "npm:sass#^1.49.9",
React still asks for node-sass after removing it and replacing it with Sass, so you can alias it like this and now React will use Sass.
I met the same issue, and here's how I was able to fix it:
Firstly, you have to know which node-sass version you are using in your project. Then go upgrade or downgrade your current Node.js version to the compatible version with your current node-sass version, you can know that from this link.
Of course, stop the server, and close your IDE.
So, the best way to upgrade or downgrade the Node.js version, has mentioned above in this answer. Then remove the node_modules, and package-lock.json and install again... You can do it as such:
npm cache clean --force
rm -rf /node_modules package-lock.json
npm install
npm audit fix
npm run <your_script_name>
If the error is
Error: Node Sass version 5.0.0 is incompatible with ^4.0.0
Step 1: stop the server
Step 2: run commands are npm uninstall node-sass
Step 3: check node-sass in package.json. If node-sass is available in the file then again run Step 2.
Step 4: npm install node-sass#4.14.1 <=== run command
Step 5: wait until the command successfully runs.
Step 6: start-server using npm start
Just change version to:
"version": "4.14.1" in your package.json file
Adding sass-loader as as dev-dependency solved this for me.
"devDependencies": { "node-sass": "^6.0.0", "sass-loader": "^11.1.1" }
Small update: In case if you get the below error in regard to node-sass, follow the steps given below.
code EPERM
npm ERR! syscall unlink
Steps to solve the issue:
Close Visual Studio
Manually remove .node-sass.DELETE from node_modules
open Visual Studio
npm cache verify
npm install node-sass#4.14.1
Delete a yarn.lock file in the project
and
yarn remove node-sass
yarn add node-sass
In app.js or wherever the css is being imported, make sure to import css and not scss. The script in package.json will create a css file and that's what should be imported.
"scss": "node-sass --watch -include-path src/scss -o src/css"
This script will watch a scss file inside of a folder called scss that is inside src. It will then create an css folder inside src and add a css file inside that folder, this is the file you should import in app.js
To run the script:
npm run scss
File structure example:
src/scss/styles.scss
CSS file created by script:
src/css/styles.css
Or else Rebuild your node-sass so that the compatibility does not produce an error.
When the incompatibility between node-sass and node occurs, you will get typescript errors .
Do this to achieve node-sass compatibility.
npm rebuild node-sass
This error is due to an incompatible version of the sass loader with node-sass.
Add these dependencies at the end of your package.json file.
Note: You can google to check which sass-loader version is compatible with your node-sass version.
"devDependencies": {
"node-sass": "^6.0.1",
"sass-loader": "^10.2.0"
}
Please note that Node Sass is deprecated and you may replace it with Dart Sass:
Warning: LibSass and Node Sass are deprecated. While they will continue to receive maintenance releases indefinitely, there are no plans to add additional features or compatibility with any new CSS or Sass features. Projects that still use it should move onto Dart Sass.
Source: node-sass
The below recipe helped me:
Uninstall node-sass:
npm: npm uninstall node-sass
yarn: yarn remove node-sass
Uninstall sass-loader:
npm: npm uninstall sass-loader
yarn: yarn remove sass-loader
Install Dart Sass as a development dependency
npm: npm install sass -dev
yarn: yarn add sass -dev
Before building, you should also:
Remove the node_modules directory
Remove lock file:
npm: Remove package-lock.json
yarn: Remove yarn.json
npm uninstall node-sass
npm i sass
Steps to resolve this issue:
Go to your node_module folder and open node-sass modules.
In the package.json file inside node-sass, change the version from "5.0.0" to "4.14.1".
Finally in the package.json at the root of the main project again change node-sass version from "5.0.0" to "4.14.4."
This should work.

Problems with babel loader in react-create-app

The Problem
create-react-app initializes a repository where babel-loader is installed as an older version than needed.
LOG:
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:
"babel-loader": "8.0.4"
Don't try to install it manually: your package manager does it automatically.
However, a different version of babel-loader was detected higher up in the tree:
C:\Users\user\node_modules\babel-loader (version: 8.0.2)
Manually installing incompatible versions is known to cause hard-to-debug issues.
If prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That will permanently disable this message but you might encounter other issues.
To fix the dependency tree, try following the steps below in the exact order:
1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
2. Delete node_modules in your project folder.
3. Remove "babel-loader" from dependencies and/or devDependencies in the package.json
file in your project folder.
4. Run npm install or yarn, depending on the package manager you use.
In most cases, this should be enough to fix
the problem.
If this has not helped, there are a few other things you can try:
5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
This may help because npm has known issues with package hoisting which may get resolved in future versions.
6. Check if C:\Users\User\node_modules\babel-loader is outside your project directory.
For example, you might have accidentally installed something in your home folder.
7. Try running npm ls babel-loader in your project folder.
This will tell you which other package
(apart from the expected react-scripts) installed babel-loader.
If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That would permanently disable this preflight check in case you want to proceed anyway.
P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! reg#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the reg#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\User\AppData\Roaming\npm-cache\_logs\2018-12-13T18_22_47_802Z-debug.log
After what it happened
$ npx create-react-app reg && cd reg && npm start
What I've tried
I tried to remove node_modules folder and package-lock.json, then run npm install.
Also installed yarn and ran yarn && yarn start.
I've recreated the app 3 times and got the same result.
Info that may be helpful
Node version: 10.8.0
NPM Version: 6.5.0
create-react-app / react-scripts: 2.1.1
babel-loader: 8.0.4
Global packages list (npm ls --depth=0 -g):
+-- create-react-app#2.1.1
+-- node-gyp#3.6.2
+-- npm#6.5.0
+-- yarn#1.12.3
package.json file:
{
"name": "reg",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.6.3",
"react-dom": "^16.6.3",
"react-scripts": "2.1.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
Getting the same issue but given an hour on it get the solution
When we run npm start then you got this kind of an error that is version related issues for this issue.
Go to node_modules folder:
Project->node_modules->react-scripts->package.json
check the package.json file
there you got : "babel-loader": "8.0.4"
first remove : babel-loader folder for Project->node_modules->babel-loader
and then run npm i babel-loader#8.0.4 (it is depend on your version you can change it like : npm i babel-loader#8.0.5) after that may be you got webpack issue then follow same thing remvoe webpack from "Project->node_modules->webpack"
and reinstall npm i webpack#4.19.1
4.19.1* webpack's version it may be change..
Create a .env file in your project directory and include SKIP_PREFLIGHT_CHECK=true in the file.
On Mac:
Remove the conflicting package from /Users/<yourusername>/node_modules
However, a different version of babel-loader was detected higher up in the tree:
You should delete babel-loader package that was was detected higher up the tree. The output says there is a node_modules folder with babel-loader at..
C:\Users\user\node_modules\babel-loader (version: 8.0.2)
You may be able to delete the C:\Users\user\node_modules directory altogether as well, unless for some reason you have a project rooted there inside /Users/{user}
A few years later, the same issue.
For me, the solution was in my c:/users/myName/node_modules.
Remove that node_modules completely and try again.
You can momentarily downgrade react-scripts to 1.1.5 in the package.json file, then remove the node_modules folder and in the case of using NPM delete the package-lock.json file and in case Yarn delete the file yarn.lock.
After that, reinstall the dependencies and start the development server with the yarn start or npm run start command.
this means you install tow babel-loader
rm yarn.lock
run npm uninstall babel-loader#8.0.4
I got the same problem.
I solved it by removing folder node_modules in User/ and file package-lock.json (if exists).
It should work perfectly then.
I had this exact same issue. For anyone who finds this thread via Google and is a beginner like me. Here is exactly what to enter into your terminal(Mac User).
Say you're getting the same error that Paul was getting:
"The react-scripts package provided by Create React App requires a dependency:
"babel-loader": "8.0.6"
Here's what I entered into the terminal. I could be wrong, but this is what worked for me (I am also a beginner):
Step 1: Delete the node_modules folder as well as the package_lock.json files.
Step 2: In your terminal, type cd - (we're just getting outside of our project folder and going into your home folder)
Step 3: In your terminal type in npm i "dependency-name#number" so for the above example it would be: npm i babel-loader#8.0.6
Step 4: Now in your terminal, navigate into your project folder and type: npm install or yarn install
Step 5: Try running npm start and if all the issues have been solved, it should start the development server.
Note: I had to do the above process twice, for babel-loader#8.0.6 as well as for Webpack.
I have also problems after creating an app-project using the following commands:
create-react-app "project name"
create-react-app "project name" --use-npm
npx create-react-app.
On all cases the result was the error specified right in the top:
[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.......][...]
watching on the error a line came with a small clue:
"/Users/john/node_modules/babel-loader (version: "7.1.5") -> was a
version that creates conflict with above specified - version
"babel-loader#8.0.6"
for me the solution was: following this path through my folders and delete the node_modules folder then restart again the project.
C:\Users\user\node_modules\babel-loader
Delete node_modules from \user\node_modules don't delete from your project
if you are using backend (nodejs) check if you are using webpack in your backend
make sure your create-react-app webpack and backend webpack version same
In the /home/<username>/node_modules/babel-loader directory just change in the package.json file the version to "8.0.4" in your case.
Worked for me
I got the same error with babel-loader#8.1.0, I removed the reference from package.json and also the module from node_modules and installed "npm i babel-loader#8.1.0" but then introduced #jest error.
I removed the #jest module from node_modules then installed the required dependency version as I did for babel-loader to solve the issue.
For me the same issue was resolved by adding "resolutions": {
"babel-loader": "8.1.0" //the required version
} in my package.json file.
Removed node-modules, yarn.loack, package-lock.json
yarn start
It worked perfectly fine
I was having this issue and just added in
"babel-loader": "8.0.4",
to my package.json in the dependencies and it seemed to fix the issue

Requires Babel "7.0.0-0" but was loaded with "6.26.3"

Keep getting this error no matter what I tried installing (babel wise) as I follow other similar reports. this is the stack trace:
error: bundling failed: Error: Requires Babel "^7.0.0-0", but was
loaded with "6.26.3". If you are sure you have a compatible version of
#babel/core, it is likely that something in your build process is
loading the wrong version. Inspect the stack trace of this error to
look for the first entry that doesn't mention "#babel/core" or
"babel-core" to see what is calling Babel. (While processing preset:
"C:\\Users\\Admin-ESS\\Absent\\node_modules\\#babel\\preset-env\\lib\\index.js")
at throwVersionError (C:\Users\Admin-ESS\Absent\node_modules\#babel\preset-env\node_modules\#babel\helper-plugin-utils\lib\index.js:65:11)
at Object.assertVersion (C:\Users\Admin-ESS\Absent\node_modules\#babel\preset-env\node_modules\#babel\helper-plugin-utils\lib\index.js:13:11)
at _default (C:\Users\Admin-ESS\Absent\node_modules\#babel\preset-env\lib\index.js:150:7)
at C:\Users\Admin-ESS\Absent\node_modules\#babel\preset-env\node_modules\#babel\helper-plugin-utils\lib\index.js:19:12
at C:\Users\Admin-ESS\Absent\node_modules\metro\node_modules\babel-core\lib\transformation\file\options\option-manager.js:317:46
at Array.map (<anonymous>)
at OptionManager.resolvePresets (C:\Users\Admin-ESS\Absent\node_modules\metro\node_modules\babel-core\lib\transformation\file\options\option-manager.js:275:20)
at OptionManager.mergePresets (C:\Users\Admin-ESS\Absent\node_modules\metro\node_modules\babel-core\lib\transformation\file\options\option-manager.js:264:10)
at OptionManager.mergeOptions (C:\Users\Admin-ESS\Absent\node_modules\metro\node_modules\babel-core\lib\transformation\file\options\option-manager.js:249:14)
at OptionManager.init (C:\Users\Admin-ESS\Absent\node_modules\metro\node_modules\babel-core\lib\transformation\file\options\option-manager.js:368:12)
at File.initOptions (C:\Users\Admin-ESS\Absent\node_modules\metro\node_modules\babel-core\lib\transformation\file\index.js:212:65)
at new File (C:\Users\Admin-ESS\Absent\node_modules\metro\node_modules\babel-core\lib\transformation\file\index.js:135:24)
at Pipeline.transform (C:\Users\Admin-ESS\Absent\node_modules\metro\node_modules\babel-core\lib\transformation\pipeline.js:46:16)
at Object.transform (C:\Users\Admin-ESS\Absent\node_modules\metro\src\transformer.js:135:5)
at Object.transformCode [as transform] (C:\Users\Admin-ESS\Absent\node_modules\metro\src\JSTransformer\worker\index.js:253:15)
at execMethod (C:\Users\Admin-ESS\Absent\node_modules\jest-worker\build\child.js:92:29)
at process.on (C:\Users\Admin-ESS\Absent\node_modules\jest-worker\build\child.js:42:7)
at process.emit (events.js:180:13)
at emit (internal/child_process.js:783:12)
and my package.json:
{
"name": "Absent",
"version": "0.1.0",
"private": true,
"devDependencies": {
"babel-preset-react-native-stage-0": "^1.0.1",
"jest": "^23.5.0",
"jest-react-native": "^18.0.0",
"react-test-renderer": "16.3.1"
},
"scripts": {
"start": "react-native start",
"android": "react-native run-android",
"ios": "react-native run-ios",
"test": "jest"
},
"jest": {
"preset": "react-native"
},
"dependencies": {
"#babel/core": "^7.0.0-rc.1",
"#babel/preset-env": "^7.0.0-rc.1",
"#babel/preset-react": "^7.0.0-rc.1",
"jail-monkey": "^1.0.0",
"prop-types": "^15.6.2",
"react": "16.3.1",
"react-native": "^0.55.4",
"react-native-device-info": "^0.22.4",
"react-native-elements": "^0.19.1",
"react-native-firebase": "^4.3.8",
"react-native-modal": "^6.5.0",
"react-native-router-flux": "^4.0.1",
"react-native-size-matters": "^0.1.2",
"react-native-vector-icons": "^5.0.0",
"react-redux": "^5.0.7",
"redux": "^4.0.0",
"redux-thunk": "^2.3.0"
},
"rnpm": {
"assets": [
"./assets/fonts/"
]
}
}
Any pointers would be greatly appreciated here...
Test which version you are running with cmd
babel -V
If it is not verion 7 or higher
npm uninstall babel-cli -g
npm uninstall babel-core -g
And
npm install #babel/cli -g
npm install #babel/core -g
If you are using Jest run
npm install babel-core#7.0.0-bridge.0 --save-dev
Uninstall and reinstall #babel/node solves the problem if you do node development.
Looks like you need to install babel-core as the docs suggest:
https://jestjs.io/docs/en/getting-started#using-babel
yarn add --dev babel-jest babel-core#^7.0.0-bridge.0 #babel/core regenerator-runtime
Sometimes its because you have installed both babel-cli and babel/cli, or babel-core and #babel/core
It causes conflicts
So
1) delete node_modules
2) remove babel-cli, babel-core from your package.json, keep #babel/core, #babel/cli
3) npm install
babel-cli conflicts with #babel/cli
bable-core conflicts with #babel/core
For the ones who still fighting that, 4 days ago Jest v24 released with native support for babel 7. enjoy.
None of the solutions I found online worked, I fixed it the following way:
Remove jest and #babel/core from package.json (keep babel-core v7 bridge)
Remove node_modules and package-lock.json
npm install
npm install jest #babel/core --save-dev
From the Babel Docs, I found that there is an issue with the order in which you install the deps.
Note: Please install #babel/cli and #babel/core first before npx babel, otherwise npx will install out-of-dated babel 6.x.
As per the usage docs. I found that removing both items from package.json and adding them in order, fixed my issue. Bizarre edge case.
The issue on my side was a conflict between babel-core, imported by babel-register, and #babel/core, required by Babel documentation for latest usage and set as root npm dependency
It seems babel-register has been moved to #babel/register. Babel didn't update docs with the new module name although they did for their cli/core packages
Here is an update of setup babel doc that works for me:
Installation
npm install --save-dev #babel/register
Usage
In your package.json file make the following changes:
{
"scripts": {
"test": "mocha --require #babel/register"
}
}
you need this 4 packages, that will fix the issue:
npm install #babel/cli
npm install #babel/core
npm install #babel/node
npm install #babel/preset-env
In my case, the issue was caused by upgrading my #babel/core version, while I kept an outdated webpack (and/or webpack-cli, I simply treated them identically in batch) version. I happened to be using a Webpack config file that was webpack.config.babel.js. Webpack seems to deal with this internally by using babel-register (see this SO answer). This was evidenced by my require stack:
at OptionManager.mergePresets (/Users/me/Projects/github-wide-mode/node_modules/babel-core/lib/transformation/file/options/option-manager.js:264:10)
at OptionManager.mergeOptions (/Users/me/Projects/my-project/node_modules/babel-core/lib/transformation/file/options/option-manager.js:249:14)
at OptionManager.init (/Users/me/Projects/my-project/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
at compile (/Users/me/Projects/my-project/node_modules/babel-register/lib/node.js:103:45)
at loader (/Users/me/Projects/my-project/node_modules/babel-register/lib/node.js:144:14)
at Object.require.extensions.<computed> [as .js] (/Users/me/Projects/my-project/node_modules/babel-register/lib/node.js:154:7)
^^^^^^^^^^^^^^
at require (/Users/me/Projects/my-project/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
at WEBPACK_OPTIONS (/Users/me/Projects/my-project/node_modules/webpack-cli/bin/utils/convert-argv.js:114:13)
at requireConfig (/Users/me/Projects/my-project/node_modules/webpack-cli/bin/utils/convert-argv.js:116:6)
So webpack-cli was calling babel-register – whose version I presume was dictated by the outdated version of webpack-cli – causing it to target an older version of #babel/babel-core than I had installed.
The solution
I uninstalled the webpack and webpack-cli packages, deleted my node_modules/ and package-lock.json, and then did a fresh npm install.
If this doesn't immediately work, I would suggest following the suggestion included in the error:
Error: Requires Babel "^7.0.0-0", but was loaded with "6.26.3". If you are sure you have a compatible version of #babel/core, it is likely that something in your build process is loading the wrong version. Inspect the stack trace of this error to look for the first entry that doesn't mention "#babel/core" or "babel-core" to see what is calling Babel.
to pinpoint what is causing (what is most likely) the dependency mismatch. I would also recommend deleting entries in your package.json's dependencies (and/or devDependencies) and then reinstalling them at the npm defaulted version, until they play nice with each other. Stripping away non-essential dependencies and resetting default dependencies should eventually work.
It is NOT recommended to install babel globally. It might be that your IDE has recognized your globally installed package and is going based off of that one. Or what is more likely is that you have have packages that conflict with each other. e.g babel-cli conflicts with #babel/cli
While you can install Babel CLI globally on your machine, it's much better to install it locally project by project.
yarn remove global #babel/cli #babel/core
In project directory...
yarn remove babel-cli
yarn add #babel/cli #babel/core #babel/node --dev
I accidentally had a file called .babelrc in my root directory with the following contents:
{
"presets": ["#babel/preset-env"]
}
After I deleted that file, I no longer got this error when running my gulp command.
Sometimes, you have a local version, so remove it so that the global version is ran:
npm uninstall babel-cli
npm uninstall babel-core
Delete node modules.
Update your devdepdencies to
"devDependencies": {
"#babel/core": "^7.13.10",
"babel-core": "^7.0.0-bridge.0",
........
}
npm install
What is the output of npm ls babel-core?
This was mine, so I removed babel-cli#6.26.0 and babel-register#6.26.0 from package.json, and installed #babel/cli and #babel/register
It might be a good idea to delete your lock file and rebuild it.
Delete node_modules
Update devDependencies to:
"devDependencies": {
"#babel/core": "^7.13.10",
"babel-core": "^7.0.0-bridge.0",
}
Install npm again:
npm install

Cannot resolve module 'react-dom'

I've seen few posts related to this type of error. But couldn't resolve in mine.
My package.json:
"react": "~0.14.7",
"webpack": "^1.12.13",
"react-hot-loader": "^3.0.0-beta.6",
.
.
I'm getting following error on webpack:
ERROR in ./public/src/main.js
Module not found: Error: Cannot resolve module 'react-dom' in C:\Users\react-example\public\src
# ./public/src/main.js 19:16-36
But in the cmd line when I did
npm -v react-dom
I get 3.10.10. react-dom is there. But I wonder why it still gives this error.
When I installed react-dom through npm "npm install react-dom", and run webpack I get following errors:
ERROR in ./~/react-dom/lib/ReactDOMNullInputValuePropHook.js
Module not found: Error: Cannot resolve 'file' or 'directory' C:\Users\react-example/node_modules/react/lib/ReactComponentTreeHook in C:\Users\react-example\node_modules\react-dom\lib
# ./~/react-dom/lib/ReactDOMNullInputValuePropHook.js 13:29-72
ERROR in ./~/react-dom/lib/ReactDOMUnknownPropertyHook.js
Module not found: Error: Cannot resolve 'file' or 'directory' C:\Users\react-example/node_modules/react/lib/ReactComponentTreeHook in C:\Users\react-example\node_modules\react-dom\lib
# ./~/react-dom/lib/ReactDOMUnknownPropertyHook.js 15:29-72
ERROR in ./~/react-dom/lib/ReactDOMInvalidARIAHook.js
Module not found: Error: Cannot resolve 'file' or 'directory' C:\Users\react-example/node_modules/react/lib/ReactComponentTreeHook in C:\Users\react-example\node_modules\react-dom\lib
# ./~/react-dom/lib/ReactDOMInvalidARIAHook.js 14:29-72
ERROR in ./~/react-dom/lib/ReactDebugTool.js
Module not found: Error: Cannot resolve 'file' or 'directory' C:\Users\react-example/node_modules/react/lib/ReactComponentTreeHook in C:\Users\react-example\node_modules\react-dom\lib
# ./~/react-dom/lib/ReactDebugTool.js 16:29-72
Please help.
Issue is react-dom is not installed, when you hit npm -v react-dom, it gives you the version of npm not react-dom version, you can check that by using npm -v or npm -v react-dom both will give you the same result.
You are checking the package version incorrectly.
How to install react and react-dom properly?
Use this to install react and react-dom:
npm install react react-dom --save
After that, you can check your package.json file, if react and react-dom has been installed correctly, you will find an entry for that.
How to check install package version?
To check all the locally installed packages version:
npm list
For globally installed packages, use -g also:
npm list -g
To check the version of any specific package, specify the package name also:
npm list PackageName
For Example =>
npm list react
npm list react-router
After installation your package.json will look like this:
{
"name": "***",
"version": "1.0.0",
"main": "***",
"scripts": {
....
},
"repository": {
....
},
"keywords": [],
"author": "",
"dependencies": {
....
"react": "^15.4.2", //react
"react-dom": "^15.4.2", //react-dom
....
},
"devDependencies": {
....
}
}
Latest version of react-dom is : 15.4.2
Reference: https://www.npmjs.com/package/react-dom
In my case I had an alias in my webpack.config.common.js:
resolve: {
extensions: ['.js', '.jsx'],
alias: {
'react-dom': '#hot-loader/react-dom',
},
},
I just removed this line:
'react-dom': '#hot-loader/react-dom',
and it was fixed.
I used 'npm update' and that solved my problem.
In my case, it was an alias I had in my webpack.conf, which was looking for #hot-loader/react-dom.
For anybody reading this that wasn't able to figure it out. I had the same issue which I ended up resolving by installing the "react-router" package which is simply running the following command
npm i react-router-dom --save for a browser app.
npm i react-router-native for a native app.
You may need to update react and react-dom. Despite react-dom actually being installed, I was having this issue on ^15.5.4 and it went away with ^16.8.6:
$ # update the react and react-dom modules
$ yarn add react react-dom
Ensure that the two version match exactly in package.json:
"react": "^16.8.6",
"react-dom": "^16.8.6",
Delete yarn.lock, node_modules, and yarn again.
rm -Rf yarn.lock node_modules && yarn
You can also try to solve this issue by updating your react react-dom module, try
npm install react#latest react-dom#latest.
Try rm -rf node_modules && yarn or rm -rf node_modules && npm install if you use npm instead of yarn.
My particular issue for getting this error:
ERROR in ./src/index.js Module not found: Error: Can't resolve
'eact-dom' in
'C:\Users\Jose\Desktop\woz-u-React\React-Course\react-lesson-one\src'
# ./src/index.js 2:0-32 # multi
(webpack)-dev-server/client?http://localhost:8080 ./src/index.js
To fix this issue, I had to unzip the folder before installing.
The following command will resolve the problem.
npm install react react-dom --save
For those using Parcel, this can occur if you are targeting Node for a browser-based app.
There are 3 ways Parcel will infer this from your package.json:
Remove node as the target, or specify the --target as browser at the command line.
Also see:
https://v2.parceljs.org/getting-started/migration/
https://v2.parceljs.org/configuration/package-json/
Your app is pointing to the global version of react hence you need install it manually using global keyword. You can also compare your installed version of react-dom in package.json of your current project and globally installed react-dom version using command npm -v react-dom if both are different then manually install react dom using command:
sudo npm install -g react-dom#17.0.2

Resources