14
votes

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?

4
Are you actually using TypeScript in your project?Matei Radu
I am not using it, do I need to install it maybe?Aleksandar Milakovic
Did you bootstrap your React project with something particular? What are your current dependencies listed in package.json?Matei Radu
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"Aleksandar Milakovic
TypeScript was problem after all, thanksAleksandar Milakovic

4 Answers

29
votes

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.

24
votes

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.

0
votes

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.

0
votes

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)