1
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.

Docker環境でnpm installのエラー出力がループして終わらない

Posted at

うっかりビルドし直したらnodeだかnpmだか、なんかが新しくなってて急激に怒られたのでその時のメモ。
Immutable Infrastructureとはいったい
ちょいちょい最新を取ってきちゃうような、あやふやな設定書いてる自分が悪い。

  • コンテナはrootで何もかもが動いている
  • aptでnodeを取りに行っていたが、最新じゃないからサポートしてやらない的なことをブツブツ言われるのでv10.16.2のバイナリを落としてきてインストールするようにした(問題のエラーとは直接関係のある変更ではなさそう)
  • Dockerfileでは-gで入れるwebpack等だけRUNでコマンドが書かれていて、アプリが使う諸々は別途シェルスクリプトを書きcmd start.shで起動、まるっとセットアップ(npm i --frozen-lockfileみたいな)している
  • frozen-lockfileが何かは知らないがバージョン固定でライブラリ入れてるんだろうねくらいの理解
  • なんでこんな薄いかんじで使ってんのかというと連携先アプリを開発環境に取り込んで起動してるから
  • 2019年6月くらいまでは起きなかったトラブル(のはず)。nodeになんかあったんでしょ知らんけど

永久に出るエラーの例

gyp verb ensuring nodedir is created /usr/src/app/node_modules/node-sass/.node-gyp/10.16.2
gyp WARN EACCES user "undefined" does not have permission to access the dev dir "/usr/src/app/node_modules/node-sass/.node-gyp/10.16.2"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/src/app/node_modules/node-sass/.node-gyp"
gyp verb tmpdir == cwd automatically will remove dev files after to save disk space
gyp verb command install [ '10.16.2' ]
gyp verb install input version string "10.16.2"
gyp verb install installing version: 10.16.2
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version not already installed, continuing with install 10.16.2

このnode-sassさんがなんかやらかしたの?とも思ったが、

user "undefined" does not have permission

まあこれですよねという感じ。undefined氏は私も知らない人です。

解決した一打

Dockerfileにこれいれる。

RUN npm -g config set user root

参考

No access permission error with npm global install on docker image - Stack Overflow
Global install file-ownership “nobody” - is this really sane ? · Issue #3849 · npm/npm

1
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
1
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?