LoginSignup
2

More than 5 years have passed since last update.

Vagrantのマウントディレクトリ上でnpm installが失敗する場合の対処法

Last updated at Posted at 2018-01-05

はじめに

ハマったのが2回目なのでメモしておく
Vagrantのマウントディレクトリ上でnpm installが失敗します。
私の場合はシンボリックリンクが作れないよ。と怒られています。

npm ERR! Linux 3.10.0-514.el7.x86_64
npm ERR! argv "/usr/bin/node" "/bin/npm" "install" "serverless-offline" "--save-dev"
npm ERR! node v6.11.1
npm ERR! npm  v3.10.10
npm ERR! path ../babylon/bin/babylon.js
npm ERR! code EPROTO
npm ERR! errno -71
npm ERR! syscall symlink

npm ERR! EPROTO: protocol error, symlink '../babylon/bin/babylon.js' -> '/mount-dir/api/node_modules/.bin/babylon'
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /mount-dir/api/npm-debug.log

対処法

VagrantがマウントされたディレクトリをVM上のディレクトリだと思わせればよさそうです。

1.VM上にnode_modulesディレクトリを作成する

mkdir /home/vagrant/node_modules

2.Vagrantでマウントされたディレクトリ上にnode_modulesディレクトリを作成する

mkdir /mount-dir/api/node_modules

3.マウントする

mount --bind /home/vagrant/vagrant_node_modules /mount-dir/api/node_modules

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