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
Related
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.
How to fix Could not find plugin "proposal-numeric-separator", I get this error when I try to build my React application, I have not ejected the application yet:
./src/index.js
Error: [BABEL] /home/pc/Downloads/project/src/index.js: Could not find plugin "proposal-numeric-separator". Ensure there is an entry in ./available-plugins.js for it. (While processing: "/home/pc/Downloads/project/node_modules/babel-preset-react-app/index.js$0")
at Array.map (<anonymous>)
at Generator.next (<anonymous>)
at Generator.next (<anonymous>)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I have tried to download Babel and the dependency Proposal Numeric Separator, remove the Node Modules, clean the Yarn cache; but nothing worked.
I'm using Yarn 1.22.4 and Node 13.11.0, but I have also tried with NPM 6.13.7.
The following steps work:
Add the following line to package.json:
"resolutions": {
"#babel/preset-env": "7.5.5"
},
Run the following command:
$ npx npm-force-resolutions
Install dependencies:
$ npm install
# or
$ yarn
Build your project:
$ yarn build
Take a look at this Github Issue
Try this, it works: npm i #babel/compat-data#7.8.0
I have just used it like 10 minutes ago, and it's working fine.
Related issue going on github about this. Click Here!
From the corresponding issue in create-react-app,
Update react-scripts to 3.4.1 in your package.json file and remove
node_modules as well as package-lock.json/yarn.lock and re-install.
Why this problem happened?:
It's an issue of conflicts between internal packages used by babel.
Adding a new plugin to #babel/compat-data breaks old #babel/preset-env versions. This is because preset-env iterates over compat-data's plugins, and throws if the plugin isn't defined in preset-env's available-plugins.js file.
This is the merge that fixed the issue: https://github.com/babel/babel/pull/11201/files/a88a00750c61ff89f1622d408d67108719f21ecd
Solution:
Delete package-lock.json or yarn.lock
Delete node_modules folder
In package.jon I have adjusted the version numbers of these packages to:
...
"devDependencies": {
"#babel/compat-data": "^7.8.0",
"#babel/preset-env": "^7.8.0",
"babel-loader": "^8.1.0",
...
},
...
"resolutions": {
"#babel/preset-env": "^7.8.0"
}
Run npm install
Run npm run build
Reference: https://github.com/angular/angular-cli/issues/17262
I found two solution
a ) Install babel compat
"devDependencies": {
"#babel/compat-data": "7.8.0",
}
b) Install plugin-proposal-numeric-separator
npm install --save-dev #babel/plugin-proposal-numeric-separator
install this version only 7.8.0
Angular CLI can create this kind of issue. Go to package json and change it to
build-angular": "0.803.17"
please don't add ^ or ~ .
I faced similar issue and i was able to fix it by updating all babel dependencies to latest version. I'm not aware of the exact issue with babel. However, the below mentioned step worked for me.
Step 1: identify and remove all babel related dependencies from package.json
npm remove #babel/runtime #babel/core #babel/plugin-proposal-class-properties #babel/plugin-transform-modules-commonjs #babel/plugin-transform-runtime #babel/preset-env #babel/preset-react babel-eslint babel-jest babel-loader
Step 2: re-install babel dependencies
npm install --save #babel/runtime
npm install --save-dev #babel/core #babel/plugin-proposal-class-properties #babel/plugin-transform-modules-commonjs #babel/plugin-transform-runtime #babel/preset-env #babel/preset-react babel-eslint babel-jest babel-loader
PS: The above list of babel dependencies will differ for your project.
I just changed react-script version from 3.0.1 to 3.4.1
You can use this command, which has worked for me.
npm i #babel/compat-data#7.8.0
I'm using angular & this worked for me, simply changed the version of #babel/compat-data from ^7.8.0 to just 7.8.0, the package-lock.json is having newer version which has bugs.
Inside package.json:
"devDependencies": {
"#babel/compat-data": "7.8.0",
}
In package.json
"dependencies": {
"#babel/compat-data": "7.8.0",
"#babel/plugin-proposal-numeric-separator": "^7.8.3",
"babel-loader": "^8.1.0",
....
"resolutions": {
"#babel/preset-env": "^7.8.7"
}
it is working for me. You can read more
https://github.com/angular/angular-cli/issues/17262#issuecomment-603396857
Its just a 4 step process.
Reason:
This happens because of a package missing in babel. This will happen even if you create angular app using ng new command.
Solution
Install plugin-proposal-numeric-separator using the following code in terminal.
npm install --save #babel/plugin-proposal-numeric-separator
Once it is done navigate to the file as shown below.
node_modules > #babel > preset-env > available-plugins.js
In available-plugins.js below exports.default = void 0; copy and paste the following code.
var _pluginProposalNumericSeparator = _interopRequireDefault(require("#babel/plugin-proposal-numeric-separator"));
In available-plugins.js within var _default object declaration copy and paste the following code.
"proposal-numeric-separator": _pluginProposalNumericSeparator.default,
And it is done.
In my angular 8 application, although I did not have any direct dependancy of react-scripts package and did not have it in package.json either but started getting this error on build. It was likely used as a depedancy by other packges.
By reading this post on github, I added it as dependancy in package.json "react-scripts": "3.4.1" and run npm install the build started working just fine.
This worked for me:
Delete package-lock.json
Delete node_modules
Run npm i
try this , this working with me .
npm i #babel/compat-data#7.8.0
Add SKIP_PREFLIGHT_CHECK=true to .env file to make the build work without ejecting and follow the below steps:
Delete node_modules and package-lock.json
Add "resolutions": { "#babel/preset-env": "^7.8.7" } to package.json
Run npm install npm-force-resolutions --save-dev
Run npm install
Run npx npm-force-resolutions
Run npm install again
Run npm run build
In my case I've got a corrupted node_modules folder.
My yarn install simply stopped in the middle by a power surge.
By running:
rm -rf node_modules
yarn
My problem was solved.
worked for me.
npm install #babel/compat-data#~7.8.0
I just had this happen to me. The To fix it I ran yarn build with sudo privileges.
I am trying to update my react project to an updated version and I am facing the following error:
ERROR in ./node_modules/react-dom/index.js
Module not found: Error: Can't resolve 'react/lib/ReactDOM' in 'C:\Users\serole\Desktop\latest_react\app\node_modules\react-dom'
# ./node_modules/react-dom/index.js 3:17-46
# ./src/index.js
# multi babel-polyfill webpack/hot/dev-server webpack-dev-server/client?http://0.0.0.0:8080/ ./src/index
i 「wdm」: Failed to compile.
i 「wdm」: Compiling...
you can remove node modules and install like this
npm install react-dom#latest react#latest --save
try to install your all package like this
it's working for me
To install react-dom run the below command:
npm install react-dom --save
Now try checking the package.json for react-dom.
You have to remove node_modules and package-lock.json.
Then try to install all modules using npm install.
And make sure in you package.json contains following modules,
"react": "^16.8.6",
"react-dom": "^16.8.6",
Use this to install react and react-dom:
npm install react react-dom --save
Make sure that your react and react-dom packages have the same version to avoid incompatibility.
For more help to check here.
Hope this will help you.
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
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.