5
3

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.

Windows10 + Vagrant + Virtual Box + docker + node.js で npm install すると text file is busy となるエラーに対処したメモ

Posted at

結論

ファイル共有でnode_modulesがうまく作られないのが原因。
node_modulesディレクトリはコンテナ内のみに隔離することで対応。

動作環境

  • windows10
  • vagrant2.1.1
  • virtualbox5.2.12
  • ubuntu-18.04
  • Docker version 18.05.0-ce, build f150324
  • docker-compose version 1.21.2, build a133471

エラーメッセージ

root@06ceade09ca6:/app# npm install
npm WARN deprecated node-uuid@1.4.8: Use uuid module instead
npm WARN rollback Rolling back ansi-regex@2.1.1 failed (this is probably harmless): ETXTBSY: text file is busy, unlink '/app/node_modules/ansi-regex/package.json.3358036472'
npm WARN rollback Rolling back acorn-dynamic-import@3.0.0 failed (this is probably harmless): ETXTBSY: text file is busy, unlink '/app/node_modules/acorn-dynamic-import/package.json.1207675771'
'/app/node_modules/budo/node_modules/minimist/package.json.1923057578'
npm WARN app@1.0.0 No repository field.

npm ERR! path /app/node_modules/array-find-index/package.json.2479725784
npm ERR! code ETXTBSY
npm ERR! errno -26
npm ERR! syscall rename
npm ERR! ETXTBSY: text file is busy, rename '/app/node_modules/array-find-index/package.json.2479725784' -> '/app/node_modules/array-find-index/package.json'

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-07-02T13_59_51_752Z-debug.log

対応方法

以下のように、コンテナのボリュームを指定してやることで、node_modulesをコンテナ内のみにおいておき、ホスト側のディレクトリを使わないようにできる。

docker-compose.yml
version: '3'
services:
  test:
    build: ./test
    volumes:
      - ../src:/app
      - /app/node_modules # コンテナ内のnode_moduleをvolumesに登録

参考

Docker と node_modules と Volume Trick
DockerでのNodeアプリ構築で学んだこと

5
3
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
5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?