13
11

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 1 year has passed since last update.

Docker コンテナ内でbash: npm: command not foundが出た場合の解決方法

Last updated at Posted at 2022-03-05

概要

DockerでLaravel環境を構築したのでスカフォールドをセットアップした。

npm installを実行すると「そんなもんねぇよ」と怒られたので対応方法をまとめる

補足

記事ではnginx:1.19 をベースイメージとしたコンテナを構築しています。
コマンドについては開発環境に応じて読み替えてください

version: "3"

services:
  web:
    image: nginx:1.19
    ports:
      - 8010:80
    depends_on:
      - laravel
    volumes:
      - ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf
      - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
      - ./src/laravel/public:/var/www/html/laravel/public
      - ./docker/storage:/var/www/html/laravel/public/storage

Laravel uiをインストール

composer require laravel/ui

aptコマンドでnpmnodeをインストール

# パッケージ一覧を更新
apt update

apt install nodejs npm

npm installを実行すると動くようになる

npm install 
npm WARN npm npm does not support Node.js v10.24.0
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
13
11
2

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
13
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?