LoginSignup
0
0

More than 1 year has passed since last update.

【Docker, EC2, Node.js】The engine "node" is incompatible with this module.

Posted at

状況

・railsアプリの環境構築をDockerで行い、ローカルで動くことを確認し、EC2にデプロイしようとした。
・githubにコードを上げて、EC2にSSHログインしてgit cloneした。
・デプロイに際して、アセットプリコンパイルをしようとして、以下のコマンドを実行した。

docker-compose run app rails assets:precompile RAILS_ENV=production

・すると、以下のようなエラーが跳ね返ってきた。

error http-proxy-middleware@2.0.1: The engine "node" is incompatible with this module. Expected version ">=12.0.0". Got "10.24.0"
error Found incompatible module.

対処法

DockerfileのNode.jsのインストールのくだりを記述している部分がいけてなかったみたい。

・修正後のDockerfile

Dockerfile
FROM ruby:3.0.0

RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
  && echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \
  && apt-get update -qq \
  && apt-get -y install imagemagick

# Node.jsをインストール 今回はこのコード↓を修正
RUN curl -sL https://deb.nodesource.com/setup_16.x | bash - && apt-get install -y nodejs

WORKDIR /riskbuster

COPY Gemfile /riskbuster/Gemfile
COPY Gemfile.lock /riskbuster/Gemfile.lock

RUN gem install bundler
RUN bundle install

インストールするNode.jsのバージョンを指定する部分(/setup_16.x)が古いと発生することのあるエラーのようだ。

参考

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