13
6

More than 3 years have passed since last update.

Reactの初期テンプレが作成出来なかった時の対処メモ

Last updated at Posted at 2020-01-11

始めに

node.jsのバージョンは11.10.1

久々にReactを勉強し直そうと、取り敢えず、技術書の手順に沿って、create-react-appでReactアプリのテンプレートを作ろうとしたら、出来なかったので、その時の対処方として残しておきます。

問題となった事象

① Reactチュートリアルも一通り復習したし、何か1冊書籍でもこなしておこうと、Reactアプリの初期テンプレを作るため、npx create-react-app react_appを実行した。

② installが終わって、生成されたファイル群を見てみると、node_modulespackage-lock.jsonpackage.jsonしか生成されていない...。

③ おかしいな...と、Terminalのログを見ると、以下のようなログが出ていた。

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のグローバルインストールはサポートされなくなりましたよ、との事。

調べてみると、この件について、issueが立っていた模様。

解決方法

Create React 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.

globalのcreate-react-appをuninstall
$npm uninstall -g create-react-app
up to date in 0.031s

次に、以下コマンドを入力します。

$which create-react-app

もし以下のようなパスが返ってきたら、これも削除します。

/usr/local/bin/create-react-app
$cd /usr/local/bin/
$rm create-react-app

再度、以下コマンドを実行してみましょう。

npx create-react-app react_app

今度は、無事作成されました。
スクリーンショット 2020-01-11 23.00.07.png

書籍終わったら、Dockerで環境作ってみよう。
よし、勉強しよう。

13
6
1

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
13
6