2

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?

1 Answer 1

5

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.

Sign up to request clarification or add additional context in comments.

3 Comments

ok, so you don't do it by updating package.json? just install it on its own? What happens if I put this on GitHub and someone else tries to use it. They will have to install all of their own dependencies?
No, this command will update your package.json for you. You can also do it by editing your package.json yourself.
yes, that was my question :-) How do I do that. I wasn't sure what I should put in and where I should put it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.