前提
Laravel 6 から、認証機能を使うためには laravel/ui
を追加インストールしなければいけなくなった。
公式ドキュメントだとwebpackのコンパイルに関しては書かれておらず、UIを適用するには、以下のコマンドを実行する必要がある。
$ npm install
$ npm run dev
参考: [https://www.techiediaries.com/laravel-authentication-tutorial/](Laravel 6 Auth Tutorial: Login/Register/Password Reset UI)
エラー
実行しようとしたら、エラーが出た。
npm ERR! @ development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
どうやら、以下が問題となっているらしい。
Error: Node Sass does not yet support your current environment: OS X 64-bit with Unsupported runtime (72)
調べていくと、 node-sass
を再インストールすればいいらしい。
が、 npm install -g node-sass
で、再度エラー。
Error: EACCES: permission denied, mkdir /Users/xxx/node_modules/node-sass/build
権限関係ならと思い、 sudo
してもだめ。
これは、そもそも npmをsudoでインストールしている と出てしまうらしい(?ちゃんと理解できてないかも?)
参照
Error: EACCES, mkdir '/usr/local/lib/node_modules/node-sass' - installing globally #1098 へのコメント
Resolving EACCES permissions errors when installing packages globally
解決方法
node バージョンマネージャーである nvm
をインストールして、そこから改めて node
をインストールする。
すでに npm
が sudo
でダウンロードされていても大丈夫。
nvm
のインストール
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash
~/.bash_profile
などに以下を追加
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
node-sass
のインストール
npm install -g node-sass
コンパイル成功
$ npm install
$ npm run dev