What to do if an error occurs when doing npm install axios in React + Typescript project
error contents
TypeScript error in / Users / /Public/workspace/todoapp/src/App.tsx(1,19):
Could not find a declaration file for module'react'.' / Users / /Public/workspace/todoapp/node_modules/react/index.js' implicitly has an'any' type.
If the 'react' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react` TS7016
App.tsx
> 1 | import React from "react";
| ^
2 | import "./App.css";
3 | import Api from "./components/Api";
4 |
approach
If you install it with yarn instead of npm, it works fine.
$yarn add axios
Finally
I couldn't understand why it didn't work on npm.
If you know the cause, please let us know.
If you have an edit request, I will add the cause.