node-sass導入、npm install時のエラー対処法

### 事象
node-sassを使用するためにモジュールをインストールしようと、npm installコマンドを入力したらエラーが起きた。


### 該当するソースコード
```
$ npm install

〜省略〜

npm ERR! code 1
npm ERR! path /Users/horitakuya/curriculum-intermediate/work/03-sass/node_modules/node-sass
npm ERR! command failed
npm ERR! command sh -c node scripts/build.js
npm ERR! Building: /Users/horitakuya/.nodebrew/node/v16.14.0/bin/node /Users/horitakuya/curriculum-intermediate/work/03-sass/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli   '/Users/horitakuya/.nodebrew/node/v16.14.0/bin/node',
npm ERR! gyp verb cli   '/Users/horitakuya/curriculum-intermediate/work/03-sass/node_modules/node-gyp/bin/node-gyp.js',
npm ERR! gyp verb cli   'rebuild',
npm ERR! gyp verb cli   '--verbose',
npm ERR! gyp verb cli   '--libsass_ext=',
npm ERR! gyp verb cli   '--libsass_cflags=',
npm ERR! gyp verb cli   '--libsass_ldflags=',
npm ERR! gyp verb cli   '--libsass_library='
npm ERR! gyp verb cli ]

〜省略〜

```

### 自分で試したこと
調査しところnode-sassのバージョンに対応しているnodeのバージョンは決まっているとのこと。
nodeのバージョンをインストールしようと下記のコマンドを実行。
```
horitakuya@horitakuyanoMacBook-Air 03-sass % sudo n 13.14.0
  installing : node-v13.14.0
       mkdir : /usr/local/n/versions/node/13.14.0
       fetch : https://nodejs.org/dist/v13.14.0/node-v13.14.0-darwin-x64.tar.xz
   installed : v13.14.0 to /usr/local/bin/node
      active : v16.14.0 at /Users/horitakuya/.nodebrew/current/bin/node
horitakuya@horitakuyanoMacBook-Air 03-sass % node -v
v16.14.0
horitakuya@horitakuyanoMacBook-Air 03-sass % nodebrew use v13.14.0
v13.14.0 is not installed
horitakuya@horitakuyanoMacBook-Air 03-sass % nodebrew install v13.14.0
v13.14.0 is not found
```
なぜかインストールできない、、、
さらに調べて違うコマンドを見つけたので実行。
```
nodebrew install-binary 12.16.3
v12.16.3 is not found

Can not fetch: https://nodejs.org/dist/v12.16.3/node-v12.16.3-darwin-arm64.tar.gz
```
またダメでした、、、
さらに調べてみると、installやinstall-binaryではなくてcompileを使用すると良いとのこと。
```
＄ nodebrew compile v12.18.3
```
上記を実行の上インストールが完了。
```
＄ nodebrew use v12.16.3
```
無事npm installができるようになりました。


### 例外
その後、別のアプリ作成時に下記のエラーが起きた。
```
error /Users/horitakuya/curriculum-advance/node_modules/node-sass: Command failed.
Exit code: 1
Command: node scripts/build.js
Arguments: 
Directory: /Users/horitakuya/curriculum-advance/node_modules/node-sass
Output:
Building: /Users/horitakuya/.nodebrew/node/v12.18.3/bin/node /Users/horitakuya/curriculum-advance/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [
gyp verb cli   '/Users/horitakuya/.nodebrew/node/v12.18.3/bin/node',
gyp verb cli   '/Users/horitakuya/curriculum-advance/node_modules/node-gyp/bin/node-gyp.js',
gyp verb cli   'rebuild',
gyp verb cli   '--verbose',
gyp verb cli   '--libsass_ext=',
gyp verb cli   '--libsass_cflags=',
gyp verb cli   '--libsass_ldflags=',
gyp verb cli   '--libsass_library='
gyp verb cli ]
gyp info using node-gyp@3.8.0
gyp info using node@12.18.3 | darwin | arm64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb `which` failed     at getNotFoundError (/Users/horitakuya/curriculum-advance/node_modules/which/which.js:13:12)
gyp verb `which` failed     at F (/Users/horitakuya/curriculum-advance/node_modules/which/which.js:68:19)
gyp verb `which` failed     at E (/Users/horitakuya/curriculum-advance/node_modules/which/which.js:80:29)
gyp verb `which` failed     at /Users/horitakuya/curriculum-advance/node_modules/which/which.js:89:16
gyp verb `which` failed     at /Users/horitakuya/curriculum-advance/node_modules/isexe/index.js:42:5
gyp verb `which` failed     at /Users/horitakuya/curriculum-advance/node_modules/isexe/mode.js:8:5
gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:168:21)
gyp verb `which` failed  python2 Error: not found: python2
gyp verb `which` failed     at getNotFoundError (/Users/horitakuya/curriculum-advance/node_modules/which/which.js:13:12)
gyp verb `which` failed     at F (/Users/horitakuya/curriculum-advance/node_modules/which/which.js:68:19)
gyp verb `which` failed     at E (/Users/horitakuya/curriculum-advance/node_modules/which/which.js:80:29)
gyp verb `which` failed     at /Users/horitakuya/curriculum-advance/node_modules/which/which.js:89:16
gyp verb `which` failed     at /Users/horitakuya/curriculum-advance/node_modules/isexe/index.js:42:5
gyp verb `which` failed     at /Users/horitakuya/curriculum-advance/node_modules/isexe/mode.js:8:5
gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:168:21) {
gyp verb `which` failed   code: 'ENOENT'
gyp verb `which` failed }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` failed Error: not found: python
gyp verb `which` failed     at getNotFoundError (/Users/horitakuya/curriculum-advance/node_modules/which/which.js:13:12)
gyp verb `which` failed     at F (/Users/horitakuya/curriculum-advance/node_modules/which/which.js:68:19)
gyp verb `which` failed     at E (/Users/horitakuya/curriculum-advance/node_modules/which/which.js:80:29)
gyp verb `which` failed     at /Users/horitakuya/curriculum-advance/node_modules/which/which.js:89:16
gyp verb `which` failed     at /Users/horitakuya/curriculum-advance/node_modules/isexe/index.js:42:5
gyp verb `which` failed     at /Users/horitakuya/curriculum-advance/node_modules/isexe/mode.js:8:5
gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:168:21)
gyp verb `which` failed  python Error: not found: python
gyp verb `which` failed     at getNotFoundError (/Users/horitakuya/curriculum-advance/node_modules/which/which.js:13:12)
gyp verb `which` failed     at F (/Users/horitakuya/curriculum-advance/node_modules/which/which.js:68:19)
gyp verb `which` failed     at E (/Users/horitakuya/curriculum-advance/node_modules/which/which.js:80:29)
gyp verb `which` failed     at /Users/horitakuya/curriculum-advance/node_modules/which/which.js:89:16
gyp verb `which` failed     at /Users/horitakuya/curriculum-advance/node_modules/isexe/index.js:42:5
gyp verb `which` failed     at /Users/horitakuya/curriculum-advance/node_modules/isexe/mode.js:8:5
gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:168:21) {
gyp verb `which` failed   code: 'ENOENT'
gyp verb `which` failed }
gyp ERR! configure error 
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at PythonFinder.failNoPython (/Users/horitakuya/curriculum-advance/node_modules/node-gyp/lib/configure.js:484:19)
gyp ERR! stack     at PythonFinder.<anonymous> (/Users/horitakuya/curriculum-advance/node_modules/node-gyp/lib/configure.js:406:16)
gyp ERR! stack     at F (/Users/horitakuya/curriculum-advance/node_modules/which/which.js:68:16)
gyp ERR! stack     at E (/Users/horitakuya/curriculum-advance/node_modules/which/which.js:80:29)
gyp ERR! stack     at /Users/horitakuya/curriculum-advance/node_modules/which/which.js:89:16
gyp ERR! stack     at /Users/horitakuya/curriculum-advance/node_modules/isexe/index.js:42:5
gyp ERR! stack     at /Users/horitakuya/curriculum-advance/node_modules/isexe/mode.js:8:5
gyp ERR! stack     at FSReqCallback.oncomplete (fs.js:168:21)
gyp ERR! System Darwin 21.4.0
gyp ERR! command "/Users/horitakuya/.nodebrew/node/v12.18.3/bin/node" "/Users/horitakuya/curriculum-advance/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/horitakuya/curriculum-advance/node_modules/node-sass
gyp ERR! node -v v12.18.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
Build failed with error code: 1
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this 
warning Error running install script for optional dependency: "/Users/horitakuya/curriculum-advance/node_modules/fsevents: Command failed.
Exit code: 1
Command: node install
Arguments: 
Directory: /Users/horitakuya/curriculum-advance/node_modules/fsevents
Output:
node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using node-pre-gyp@0.12.0
node-pre-gyp info using node@12.18.3 | darwin | arm64
node-pre-gyp WARN Using request for node-pre-gyp https download 
node-pre-gyp info check checked for \"/Users/horitakuya/curriculum-advance/node_modules/fsevents/lib/binding/Release/node-v72-darwin-arm64/fse.node\" (not found)
node-pre-gyp http GET https://fsevents-binaries.s3-us-west-2.amazonaws.com/v1.2.9/fse-v1.2.9-node-v72-darwin-arm64.tar.gz
node-pre-gyp http 404 https://fsevents-binaries.s3-us-west-2.amazonaws.com/v1.2.9/fse-v1.2.9-node-v72-darwin-arm64.tar.gz
node-pre-gyp WARN Tried to download(404): https://fsevents-binaries.s3-us-west-2.amazonaws.com/v1.2.9/fse-v1.2.9-node-v72-darwin-arm64.tar.gz 
node-pre-gyp WARN Pre-built binaries not found for fsevents@1.2.9 and node@12.18.3 (node-v72 ABI, unknown) (falling back to source compile with node-gyp) 
node-pre-gyp http 404 status code downloading tarball https://fsevents-binaries.s3-us-west-2.amazonaws.com/v1.2.9/fse-v1.2.9-node-v72-darwin-arm64.tar.gz 
gyp info it worked if it ends with ok
gyp info using node-gyp@3.8.0
gyp info using node@12.18.3 | darwin | arm64
gyp info ok 
gyp info it worked if it ends with ok
gyp info using node-gyp@3.8.0
gyp info using node@12.18.3 | darwin | arm64
gyp ERR! configure error 
gyp ERR! stack Error: Can't find Python executable \"python\", you can set the PYTHON env variable.
gyp ERR! stack     at PythonFinder.failNoPython (/Users/horitakuya/curriculum-advance/node_modules/node-gyp/lib/configure.js:484:19)
gyp ERR! stack     at PythonFinder.<anonymous> (/Users/horitakuya/curriculum-advance/node_modules/node-gyp/lib/configure.js:406:16)
gyp ERR! stack     at F (/Users/horitakuya/curriculum-advance/node_modules/which/which.js:68:16)
gyp ERR! stack     at E (/Users/horitakuya/curriculum-advance/node_modules/which/which.js:80:29)
gyp ERR! stack     at /Users/horitakuya/curriculum-advance/node_modules/which/which.js:89:16
gyp ERR! stack     at /Users/horitakuya/curriculum-advance/node_modules/isexe/index.js:42:5
gyp ERR! stack     at /Users/horitakuya/curriculum-advance/node_modules/isexe/mode.js:8:5
gyp ERR! stack     at FSReqCallback.oncomplete (fs.js:168:21)
gyp ERR! System Darwin 21.4.0
gyp ERR! command \"/Users/horitakuya/.nodebrew/node/v12.18.3/bin/node\" \"/Users/horitakuya/curriculum-advance/node_modules/node-gyp/bin/node-gyp.js\" \"configure\" \"--fallback-to-build\" \"--module=/Users/horitakuya/curriculum-advance/node_modules/fsevents/lib/binding/Release/node-v72-darwin-arm64/fse.node\" \"--module_name=fse\" \"--module_path=/Users/horitakuya/curriculum-advance/node_modules/fsevents/lib/binding/Release/node-v72-darwin-arm64\" \"--napi_version=6\" \"--node_abi_napi=napi\" \"--napi_build_version=0\" \"--node_napi_label=node-v72\"
gyp ERR! cwd /Users/horitakuya/curriculum-advance/node_modules/fsevents
gyp ERR! node -v v12.18.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/Users/horitakuya/.nodebrew/node/v12.18.3/bin/node /Users/horitakuya/curriculum-advance/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/horitakuya/curriculum-advance/node_modules/fsevents/lib/binding/Release/node-v72-darwin-arm64/fse.node --module_name=fse --module_path=/Users/horitakuya/curriculum-advance/node_modules/fsevents/lib/binding/Release/node-v72-darwin-arm64 --napi_version=6 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/horitakuya/curriculum-advance/node_modules/fsevents/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
node-pre-gyp ERR! System Darwin 21.4.0
node-pre-gyp ERR! command \"/Users/horitakuya/.nodebrew/node/v12.18.3/bin/node\" \"/Users/horitakuya/curriculum-advance/node_modules/fsevents/node_modules/node-pre-gyp/bin/node-pre-gyp\" \"install\" \"--fallback-to-build\"
node-pre-gyp ERR! cwd /Users/horitakuya/curriculum-advance/node_modules/fsevents
node-pre-gyp ERR! node -v v12.18.3
node-pre-gyp ERR! node-pre-gyp -v v0.12.0
node-pre-gyp ERR! not ok 
Failed to execute '/Users/horitakuya/.nodebrew/node/v12.18.3/bin/node /Users/horitakuya/curriculum-advance/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/horitakuya/curriculum-advance/node_modules/fsevents/lib/binding/Release/node-v72-darwin-arm64/fse.node --module_name=fse --module_path=/Users/horitakuya/curriculum-advance/node_modules/fsevents/lib/binding/Release/node-v72-darwin-arm64 --napi_version=6 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)"
info This module is OPTIONAL, you can safely ignore this error
horitakuya@horitakuyanoMacBook-Air curriculum-advance % cd ~     
horitakuya@horitakuyanoMacBook-Air ~ % nodebrew compile v13.9.0
Fetching: https://nodejs.org/dist/v13.9.0/node-v13.9.0.tar.gz
######################################################################### 100.0%
./configure: line 7: exec: python: not found
```

原因は前述した内容と同じで、node-sassをサポートしているnode.jsのバージョンが合っていなかったことだが、
なぜかnodebrew compileで違うバージョンをインストールできなかった。

nodebrewはしっかりインストールできていたので、一度コマンドラインでルートディレクトリへ移動し下記のコマンドを実行。

```
nodebrew install-binary v13.9.0
```
無事インストールでき、エラーも解消した。
nodeのインストールはルートディレクトリに移動して実行するようにする。