環境
・macOS Big Sur バージョン11.6
AmplifyチュートリアルのためにReactアプリを作成するためのコマンドを実行すると、以下のメッセージがターミナルの標準出力に出力されました。
$ npx create-react-app amplifyapp
You are running Node 12.18.0.
Create React App requires Node 14 or higher.
Please update your version of Node.
確かに今のNode.jsのバージョンは12.18.0。
$ node -v
v12.18.0
結構前にNode.jsのバージョン管理ツール「n」をインストールしていたので、コマンドを打ってみました。n ls
でダウンロードしたバージョンが表示されます。
$ n ls
find: /usr/local/n/versions: No such file or directory
どうやらインストールしただけで、Node.jsのどのバージョンのダウンロードも行っていなかったようです。
最新のNode.jsのダウンロードを行います。sudo
を付けていますが、環境によっては付けずに実行できると思います(私は付けろと怒られました)。
$ sudo n latest
Password:
installing : node-v18.0.0
mkdir : /usr/local/n/versions/node/18.0.0
fetch : https://nodejs.org/dist/v18.0.0/node-v18.0.0-darwin-x64.tar.xz
installed : v18.0.0 (with npm 8.6.0)
Node.js最新版のダウンロードが完了です。
$ node -v
v18.0.0
Reactアプリの作成コマンドを再実行すると、無事成功しました。
$ npx create-react-app amplifyapp
Creating a new React app in /Users/xxx/aws/amplify/react-tutorial/amplifyapp.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
added 1380 packages in 2m
178 packages are looking for funding
run `npm fund` for details
Initialized a git repository.
Installing template dependencies using npm...
npm WARN deprecated source-map-resolve@0.6.0: See https://github.com/lydell/source-map-resolve#deprecated
added 39 packages in 9s
178 packages are looking for funding
run `npm fund` for details
Removing template package using npm...
removed 1 package, and audited 1419 packages in 3s
178 packages are looking for funding
run `npm fund` for details
6 moderate severity vulnerabilities
To address all issues (including breaking changes), run:
npm audit fix --force
Run `npm audit` for details.
Created git commit.
Success! Created amplifyapp at /Users/xxx/aws/amplify/react-tutorial/amplifyapp
Inside that directory, you can run several commands:
npm start
Starts the development server.
npm run build
Bundles the app into static files for production.
npm test
Starts the test runner.
npm run eject
Removes this tool and copies build dependencies, configuration files
and scripts into the app directory. If you do this, you can’t go back!
We suggest that you begin by typing:
cd amplifyapp
npm start
Happy hacking!