18

I am new to React and, starting with building an app, I came up with a problem while installing dependencies. I wanted to include packages like material-ui/core, material-ui/icons, react-reveal, react-scroll and react-slick.

While installing with this command:

npm install @material-ui/core @material-ui/icons react-reveal react-scroll react-slick

It showed that they've been installed, and when I started coding it didn't compile it.

That's when I came up with this error:

npm WARN @typescript-eslint/[email protected] requires a peer of typescript@* but none is installed. You must install peer dependencies yourself.

npm WARN @typescript-eslint/[email protected] requires a peer of typescript@* but none is installed. You must install peer dependencies yourself.

npm WARN @typescript-eslint/[email protected] requires a peer of typescript@* but none is installed. You must install peer dependencies yourself.

npm WARN [email protected] requires a peer of typescript@* but none is installed. You must install peer dependencies yourself.

npm WARN [email protected] requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev but none is installed. You must install peer dependencies yourself.

What am I missing?

6
  • 1
    Are you actually using TypeScript in your project? Commented Jul 5, 2019 at 17:47
  • I am not using it, do I need to install it maybe? Commented Jul 5, 2019 at 18:56
  • Did you bootstrap your React project with something particular? What are your current dependencies listed in package.json? Commented Jul 6, 2019 at 6:47
  • i didn use bootstrap. These are currently in package: "@material-ui/core": "^4.1.3", "@material-ui/icons": "^4.2.1", "react": "^16.8.6", "react-dom": "^16.8.6", "react-reveal": "^1.2.2", "react-scripts": "3.0.1", "react-scroll": "^1.7.12", "react-slick": "^0.24.0" Commented Jul 6, 2019 at 14:53
  • 1
    TypeScript was problem after all, thanks Commented Jul 6, 2019 at 18:05

5 Answers 5

31

try this:

  1. Delete 'package-lock.json' file
  2. In the Terminal go to the folder with your project and type 'npm install --save typescript'
  3. Then type 'npm install'

It helped me.

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

Comments

27

You can also resolve this issue by just installing typescript (it's clearly written in the debug output)

$ npm install typescript

You may also use other package-managers in favor of npm like pnpm or yarn.

Update: You can also use an npm package that does this for you. Helpful when there are many peer dependencies.

The package is npm-install-peers. If you want slightly more control over these, you may want to check out install-peerdeps

Also, please do a further read on this StackOverflow answer.

Comments

1

I will list every little bit of gory detail, just in case for some people it is helpful:

  1. Remove package-lock.json (rm package-lock.json) if necessary
  2. yarn add @material-ui/core @material-ui/icons react-reveal react-scroll react-slick
  3. Read messages to make sure the dependencies were added. If you see any, then yarn add them as well.
  4. Change into your node_modules directory (cd node_modules) then list to make sure all your packages and dependencies were installed (ls)
  5. Check your App.js to make sure your import has the correct path (whether you really should have a ../ or not)
  6. Go to the browser tab that is running localhost:3000
  7. Refresh the page (For Chrome, it's the upper left clockwise arrow to the left of where you enter the URL)

Comments

0

While trying to reproduce the same error, on a Windows 10 machine with Node and npm installed, created an app with

npx create-react-app APP_NAME

If I run

npm start

the application will run just fine if I go to http://localhost:3000/

React App


In order to fix the problem you're getting, I'd just install Typescript

npm install typescript

and that should suffice.

Comments

0

add this in package.json:

"peerDependenciesMeta": {
"typescript": {
  "optional": true
}

}

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.