0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

laravel環境構築 および migrateができず詰まったのメモ

Last updated at Posted at 2020-03-18

環境構築の手順

1 create your own .env file / .envファイルを作る

cp .env.example .env.local

* .env.local is generally included in the .gitignore / .gitignoreファイルに.env.localが基本的に含まれている

Create your database, and put the login information in the .env.local file / データベースを作成し、ログイン情報を.env.localファイルに入れる

2 Copy your .env.local file to .env / .env.local ファイルを .env ファイルにコピーする

cp .env.local .env

3 Run composer / composer を実行する

composer update

4 Run npm install / npm install を実行する

npm install

5 Run npm / npm を実行する。 *npm updateしないとダメかも(下のハマったことに記載)

npm run dev

6 Create key / key を生成させる

php artisan key:generate

7 Run migration and seed / migrationとseed を実行する

php artisan migrate

php artisan db:seed

8 Serve on local machine / ローカルでホストする/サーバーの起動

php artisan serve

当たり前にローカルにデータベース作り忘れてたらダメ

 ハマったこと

php artisan migrateの失敗

画像のようなエラーが発生した。
以下の記事を参考に設定したが、上手くいかず。
【Laravel】初期設定でDB設定(MySQL)にハマったので抜け方解説

database.phpと.envの設定を確認するもだめだった..
スクリーンショット 2020-03-18 18.13.41.png

dbへの接続を確認することにした。もしかしたらパスワードが間違っているかもしれない。
そこで、$ mysql -u root -pで確認したら、そもそもパスワード設定してなかったわ笑

migrateした時には.envファイルdatabase.phpより優先的に読み込まれるので、.envファイルのパスワードを変更したらいけた。
しょうもないことに時間をかけてしまった

npm install の失敗

npm installを実施するとエラーが発生。
npmパッケージで脆弱性がある場合に出るらしい。そこで、

  1. npm audit fix
  2. npm update ←これで脆弱性のパッケージの自動修正してくれる
  3. npm isntall
$ npm install すると

npm install

> fsevents@1.2.11 install /Users/aki/Desktop/karute/src/node_modules/fsevents
> node-gyp rebuild

  SOLINK_MODULE(target) Release/.node
  CXX(target) Release/obj.target/fse/fsevents.o
  SOLINK_MODULE(target) Release/fse.node
added 1122 packages from 503 contributors and audited 17454 packages in 20.645s
found 40 low severity vulnerabilities
  run `npm audit fix` to fix them, or `npm audit` for details
 
0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?