始めに
node.jsのバージョンは11.10.1
久々にReactを勉強し直そうと、取り敢えず、技術書の手順に沿って、create-react-app
でReactアプリのテンプレートを作ろうとしたら、出来なかったので、その時の対処方として残しておきます。
問題となった事象
① Reactチュートリアルも一通り復習したし、何か1冊書籍でもこなしておこうと、Reactアプリの初期テンプレを作るため、npx create-react-app react_app
を実行した。
② installが終わって、生成されたファイル群を見てみると、node_modules
、package-lock.json
、package.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.
$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
書籍終わったら、Dockerで環境作ってみよう。
よし、勉強しよう。