LoginSignup
56
22

More than 3 years have passed since last update.

ひさしぶりにcreate-react-appしたらテンプレートができなかった時の対処法

Last updated at Posted at 2019-12-08

概要

ひさりぶりに create-react-app で React アプリの初期テンプレートを作ろうとしたら、テンプレートができなかったので、その対処法です。

発生条件

前にcreate-react-appをグローバルインストールしたことがある。

事象

create-react-appでテンプレートを作った時、package.jsonとnode_moduleぐらいしかできず、npm startができなかった。

create-react-appした時のログを見返すと、最後の方にこんなログが出ていた。

A template was not provided. This is likely because you're using an outdated version of create-react-app.
Please note that global installs of create-react-app are no longer supported.

解決策

公式ページ書いてある通り、(グローバルインストールした create-react-app をアンインストールして問題ない環境であれば) create-react-app を一度アンインストールする。
その後、npx create-react-app アプリ名で作成する。

npm uninstall -g create-react-app
npx create-react-app my-app

ソース

If you've previously installed create-react-app globally via npm install -g create-react-app, we recommend you uninstall the package using npm uninstall -g create-react-app to ensure that npx always uses the latest version.

参考

いつからこうなったのか不明ですが、2019/12/5にStack Overflowで質問が上がっていたので、割と最近かもしれないです。

Template not provided using create-react-app

解決策の補足

なお、下記でコメントいただいた情報によると、アンインストールがうまくいかない場合があるようです。

その場合、MacやLinuxなどwhichコマンドがある環境であれば、ターミナル上で、

which create-react-app

と実行した時に、次のようなcreate-react-appのパスが表示されたら、

/usr/local/bin/create-react-app

それを削除するか移動させると解決する場合があるようです。(試す場合、必要に応じてバックアップなどしてください)

56
22
2

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
56
22