LoginSignup
0
0

More than 3 years have passed since last update.

create-react-appでのパッケージマネージャー

Posted at

今回create-react-appで環境構築をした後、npm installでライブラリなどをインストールした際に起きたビルドエラーの対処法を備忘録として残します。

環境構築

npx create-react-app my-app --template redux-typescript

上記コマンドで環境を作りmaterial-uiなどをnpm installで入れた後にnpm startをした時に
下記のビルドエラーが発生。

Could not find a declaration file for module ‘react’. implicitly has an ‘any’ type. If the ‘react’ package actually exposes this module, consider sending a pull request to amend

原因

調べてみると、どうやらcreate-react-appではデフォルトでパッケージマネージャーにyarnを使用されていて、既存のnode_modulesがyarnで作成されているのに対して、npmで追加の依存関係をインストールしたことが原因だとのこと。

解決方法

node_modulesとyarn.lockファイル削除し、npm installする。
すると新たにnode_modulesフォルダが生成され、最初にインストールしていたmaterial-uiなども全てインストールされます。

参考記事

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0