Issue
I created a React project with Create-React-App. The package.json
file shows:
{
"name": "dashboard",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^15.5.4",
"react-dom": "^15.5.4"
},
"devDependencies": {
"react-scripts": "1.0.7"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
How do I add Redux? What command do I run to install it into my node_modules?
Solution
The npm command to add redux
is:
npm install --save redux
This will modify your package.json
file by adding redux
as a dependency and download the package to your node_modules
directory.
Your package.json
file will look something like this afterwards:
{
"name": "dashboard",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^15.5.4",
"react-dom": "^15.5.4",
"redux": "^3.6.0"
},
"devDependencies": {
"react-scripts": "1.0.7"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
You could also add the line with redux
(under dependencies
) yourself.
If you do that, you'll have to run npm install
afterwards so that the redux
package is added to your node_modules
.
Answered By - Patrick Hund
Answer Checked By - - Gilberto Lyons (ReactFix Admin)