エラー内容
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 |
対処法
npmではなくyarnでインストールすれば正しく動きます。
$yarn add axios
最後に
なぜnpmでは動かないのか調べても理解できませんでした。
原因をご存知の方は是非教えてください。
編集リクエストをいただければ、原因を追記しようと思います。