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

Docker alpineベースの環境でnode-gypのエラーが出た

Posted at

はじめに

Dockerでnodejsの環境をalpineベースで作成し、
supabase-jsをインストールしようとしたところ以下エラーが発生したのを修正した時のメモ。

エラー時の状況・原因・解消方法

発現時の状況

Dockerfile
FROM node:18.13-alpine3.16

RUN apk update

WORKDIR /var/www/app

USER node

CMD ["yarn", "dev"]
docker-compose.yml
version: '3'

services:
  app:
    build: .
    ports:
      - "8080:8080"
    volumes:
      - "./front:/var/www/app"
    tty: true
$ docker-compose exec app sh
/var/www/app $ yarn add @supabase/supabase-js

・
・
・
gyp ERR! find Python 
gyp ERR! find Python Python is not set from command line or npm configuration
gyp ERR! find Python Python is not set from environment variable PYTHON
gyp ERR! find Python checking if "python3" can be used
gyp ERR! find Python - "python3" is not in PATH or produced an error
gyp ERR! find Python checking if "python" can be used
gyp ERR! find Python - "python" is not in PATH or produced an error
gyp ERR! find Python 
gyp ERR! find Python **********************************************************
gyp ERR! find Python You need to install the latest version of Python.
gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
gyp ERR! find Python you can try one of the following options:
gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
gyp ERR! find Python   (accepted by both node-gyp and npm)
gyp ERR! find Python - Set the environment variable PYTHON
gyp ERR! find Python - Set the npm configuration variable python:
gyp ERR! find Python   npm config set python "/path/to/pythonexecutable"
gyp ERR! find Python For more information consult the documentation at:
gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
gyp ERR! find Python **********************************************************

エラーの原因・解消方法

  • node-gypの依存関係で起こったエラー。
  • node-gypとは、Node.jsのモジュールをコンパイルするコマンドラインツール。

公式のGithubを確認したところ、依存関係にはmakeやpythonが必要なようでした。

スクリーンショット 2023-01-21 17.10.54.png

make gcc g++ pythonの4つの依存関係をインストールすることで依存関係のエラーは解消できそうです。

Dockerfileの変更

FROM node:18.13-alpine3.16

# 変更
RUN apk update && \
    apk upgrade && \
    apk add --no-cache make gcc g++ python3

WORKDIR /var/www/app

USER node

CMD ["yarn", "dev"]

変更後無事インストールできました!

/var/www/app $ yarn add @supabase/supabase-js
yarn add v1.22.19

・
・
・

├─ whatwg-url@5.0.0
└─ yaeti@0.0.6
Done in 12.07s.
/var/www/app $ 
2
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
2
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?