# 環境

mac M1チップ  
os bigsur

# 内容

[React x
LaravelのSPAで作るチュートリアル①(環境構築編)](https://qiita.com/morry_48/items/abd620f051fb4f36dcc2)

を参考にdockerでlaravelとreactの開発環境を構築しています。

上記リンクの通りに進めて
[Reactの環境構築](https://qiita.com/morry_48/items/abd620f051fb4f36dcc2#react%E3%81%AE%E7%92%B0%E5%A2%83%E6%A7%8B%E7%AF%89)
の部分の手前までは問題なくできたのですが、  
`make npm` を実行すると以下のエラーが出ました。

```

    make: *** No rule to make target `npm'.  Stop.
    
```

Makefileに不備があると思い、以下の通り修正しました。

**修正前:**

```

    up:
        docker compose up -d
    build:
        docker compose build --no-cache --force-rm
    laravel-install:
        docker compose exec app composer create-project --prefer-dist laravel/laravel .
    create-project:
        mkdir -p src
        @make build
        @make up
        @make laravel-install
        docker compose exec app php artisan key:generate
        docker compose exec app php artisan storage:link
        docker compose exec app chmod -R 777 storage bootstrap/cache
        @make fresh
    install-recommend-packages:
        docker compose exec app composer require doctrine/dbal
        docker compose exec app composer require --dev ucan-lab/laravel-dacapo
        docker compose exec app composer require --dev barryvdh/laravel-ide-helper
        docker compose exec app composer require --dev beyondcode/laravel-dump-server
        docker compose exec app composer require --dev barryvdh/laravel-debugbar
        docker compose exec app composer require --dev roave/security-advisories:dev-master
        docker compose exec app php artisan vendor:publish --provider="BeyondCode\DumpServer\DumpServerServiceProvider"
        docker compose exec app php artisan vendor:publish --provider="Barryvdh\Debugbar\ServiceProvider"
    init:
        docker compose up -d --build
        docker compose exec app composer install
        docker compose exec app cp .env.example .env
        docker compose exec app php artisan key:generate
        docker compose exec app php artisan storage:link
        docker compose exec app chmod -R 777 storage bootstrap/cache
        @make fresh
    remake:
        @make destroy
        @make init
    stop:
        docker compose stop
    down:
        docker compose down --remove-orphans
    down-v:
        docker compose down --remove-orphans --volumes
    restart:
        @make down
        @make up
    destroy:
        docker compose down --rmi all --volumes --remove-orphans
    ps:
        docker compose ps
    logs:
        docker compose logs
    logs-watch:
        docker compose logs --follow
    log-web:
        docker compose logs web
    log-web-watch:
        docker compose logs --follow web
    log-app:
        docker compose logs app
    log-app-watch:
        docker compose logs --follow app
    log-db:
        docker compose logs db
    log-db-watch:
        docker compose logs --follow db
    web:
        docker compose exec web bash
    app:
        docker compose exec app bash
    migrate:
        docker compose exec app php artisan migrate
    fresh:
        docker compose exec app php artisan migrate:fresh --seed
    seed:
        docker compose exec app php artisan db:seed
    dacapo:
        docker compose exec app php artisan dacapo
    rollback-test:
        docker compose exec app php artisan migrate:fresh
        docker compose exec app php artisan migrate:refresh
    tinker:
        docker compose exec app php artisan tinker
    test:
        docker compose exec app php artisan test
    optimize:
        docker compose exec app php artisan optimize
    optimize-clear:
        docker compose exec app php artisan optimize:clear
    cache:
        docker compose exec app composer dump-autoload -o
        @make optimize
        docker compose exec app php artisan event:cache
        docker compose exec app php artisan view:cache
    cache-clear:
        docker compose exec app composer clear-cache
        @make optimize-clear
        docker compose exec app php artisan event:clear
    db:
        docker compose exec db bash
    sql:
        docker compose exec db bash -c 'mysql -u $$MYSQL_USER -p$$MYSQL_PASSWORD $$MYSQL_DATABASE'
    redis:
        docker compose exec redis redis-cli
    ide-helper:
        docker compose exec app php artisan clear-compiled
        docker compose exec app php artisan ide-helper:generate
        docker compose exec app php artisan ide-helper:meta
        docker compose exec app php artisan ide-helper:models --nowrite
    
```

**修正後:**

```

    up:
        docker-compose up -d
    build:
        docker-compose build --no-cache --force-rm
    laravel-install:
        docker-compose exec app composer create-project --prefer-dist laravel/laravel .
    create-project:
        @make build
        @make up
        @make laravel-install
        docker-compose exec app php artisan key:generate
        docker-compose exec app php artisan storage:link
        docker-compose exec app chmod -R 777 storage bootstrap/cache
        @make fresh
    install-recommend-packages:
        docker-compose exec app composer require doctrine/dbal "^2"
        docker-compose exec app composer require --dev ucan-lab/laravel-dacapo
        docker-compose exec app composer require --dev barryvdh/laravel-ide-helper
        docker-compose exec app composer require --dev beyondcode/laravel-dump-server
        docker-compose exec app composer require --dev barryvdh/laravel-debugbar
        docker-compose exec app composer require --dev roave/security-advisories:dev-master
        docker-compose exec app php artisan vendor:publish --provider="BeyondCode\DumpServer\DumpServerServiceProvider"
        docker-compose exec app php artisan vendor:publish --provider="Barryvdh\Debugbar\ServiceProvider"
    init:
        docker-compose up -d --build
        docker-compose exec app composer install
        docker-compose exec app cp .env.example .env
        docker-compose exec app php artisan key:generate
        docker-compose exec app php artisan storage:link
        docker-compose exec app chmod -R 777 storage bootstrap/cache
        @make fresh
    remake:
        @make destroy
        @make init
    stop:
        docker-compose stop
    down:
        docker-compose down --remove-orphans
    restart:
        @make down
        @make up
    destroy:
        docker-compose down --rmi all --volumes --remove-orphans
    destroy-volumes:
        docker-compose down --volumes --remove-orphans
    ps:
        docker-compose ps
    logs:
        docker-compose logs
    logs-watch:
        docker-compose logs --follow
    log-web:
        docker-compose logs web
    log-web-watch:
        docker-compose logs --follow web
    log-app:
        docker-compose logs app
    log-app-watch:
        docker-compose logs --follow app
    log-db:
        docker-compose logs db
    log-db-watch:
        docker-compose logs --follow db
    web:
        docker-compose exec web ash
    app:
        docker-compose exec app bash
    migrate:
        docker-compose exec app php artisan migrate
    fresh:
        docker-compose exec app php artisan migrate:fresh --seed
    seed:
        docker-compose exec app php artisan db:seed
    dacapo:
        docker-compose exec app php artisan dacapo
    rollback-test:
        docker-compose exec app php artisan migrate:fresh
        docker-compose exec app php artisan migrate:refresh
    tinker:
        docker-compose exec app php artisan tinker
    test:
        docker-compose exec app php artisan test
    optimize:
        docker-compose exec app php artisan optimize
    optimize-clear:
        docker-compose exec app php artisan optimize:clear
    cache:
        docker-compose exec app composer dump-autoload -o
        @make optimize
        docker-compose exec app php artisan event:cache
        docker-compose exec app php artisan view:cache
    cache-clear:
        docker-compose exec app composer clear-cache
        @make optimize-clear
        docker-compose exec app php artisan event:clear
    npm:
        @make npm-install
    npm-install:
        docker-compose exec web npm install
    npm-dev:
        docker-compose exec web npm run dev
    npm-watch:
        docker-compose exec web npm run watch
    npm-watch-poll:
        docker-compose exec web npm run watch-poll
    npm-hot:
        docker-compose exec web npm run hot
    yarn:
        docker-compose exec web yarn
    yarn-install:
        @make yarn
    yarn-dev:
        docker-compose exec web yarn dev
    yarn-watch:
        docker-compose exec web yarn watch
    yarn-watch-poll:
        docker-compose exec web yarn watch-poll
    yarn-hot:
        docker-compose exec web yarn hot
    db:
        docker-compose exec db bash
    sql:
        docker-compose exec db bash -c 'mysql -u $$MYSQL_USER -p$$MYSQL_PASSWORD $$MYSQL_DATABASE'
    redis:
        docker-compose exec redis redis-cli
    ide-helper:
        docker-compose exec app php artisan clear-compiled
        docker-compose exec app php artisan ide-helper:generate
        docker-compose exec app php artisan ide-helper:meta
        docker-compose exec app php artisan ide-helper:models --nowrite
    
```

再度 `make npm` を実行すると以下のエラーが出ます。

```

    docker-compose exec web npm install
    OCI runtime exec failed: exec failed: container_linux.go:380: starting container process caused: exec: "npm": executable file not found in $PATH: unknown
    make[1]: *** [npm-install] Error 126
    make: *** [npm] Error 2
    
```

調べても原因がわからず前に進めない状態です。  
何が原因かわかる方はいらっしゃいますでしょうか？よろしくお願いいたします。
CC BY-SA 4.0
2022-03-22T05:13:41.750
87960
2022-03-22T05:31:52.273
2022-03-22T05:31:52.273
3060
51909
question
docker laravel npm
docker で make npm ができない