Vagrant 和 NPM 安装在共享文件夹上

Vagrant and NPM install on shared folder

我有一个 Ubuntu 14 64 位的 vagrant VM。我的主机是 Windows 8.1。我正在尝试在共享文件夹(nodejs 应用程序)上安装 npm,但即使使用

npm install --no-bin-links

它失败了

npm ERR! tar.unpack untar error /root/.npm/node-pre-gyp/0.6.8/package.tgz
npm ERR! tar.unpack untar error /root/.npm/node-pre-gyp/0.6.8/package.tgz
npm ERR! tar.unpack untar error /root/.npm/lodash-node/2.4.1/package.tgz
npm ERR! Linux 3.2.0-23-generic
npm ERR! argv "/usr/local/node/node-v0.12.7/bin/node" "/usr/local/node/node-default/bin/npm" "install" "--no-bin-links"
npm ERR! node v0.12.7
npm ERR! npm  v2.11.3
npm ERR! path /vagrant_data/fe/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/fs-extra/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_
modules/brace-expansion/node_modules/concat-map/package.json.1e22b31c2e50debaced0adc67bb0250c
npm ERR! code EPERM
npm ERR! errno -1

npm ERR! Error: EPERM, open '/vagrant_data/fe/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/fs-extra/node_modules/rimraf/node_modules/glob/node_modules/
minimatch/node_modules/brace-expansion/node_modules/concat-map/package.json.1e22b31c2e50debaced0adc67bb0250c'
npm ERR!     at Error (native)
npm ERR!  { [Error: EPERM, open '/vagrant_data/fe/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/fs-extra/node_modules/rimraf/node_modules/glob/node_modu
les/minimatch/node_modules/brace-expansion/node_modules/concat-map/package.json.1e22b31c2e50debaced0adc67bb0250c']
npm ERR!   errno: -1,
npm ERR!   code: 'EPERM',
npm ERR!   path: '/vagrant_data/fe/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/fs-extra/node_modules/rimraf/node_modules/glob/node_modules/minimatch/n
ode_modules/brace-expansion/node_modules/concat-map/package.json.1e22b31c2e50debaced0adc67bb0250c' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! Linux 3.2.0-23-generic
npm ERR! argv "/usr/local/node/node-v0.12.7/bin/node" "/usr/local/node/node-default/bin/npm" "install" "--no-bin-links"
npm ERR! node v0.12.7
npm ERR! npm  v2.11.3
npm ERR! path npm-debug.log.2e07d69aba2393c854d2992b7057b4c0
npm ERR! code ETXTBSY
npm ERR! errno -26

npm ERR! ETXTBSY, rename 'npm-debug.log.2e07d69aba2393c854d2992b7057b4c0'
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!     /vagrant_data/fe/npm-debug.log

我真的不明白为什么。我的 npm 版本是 2.11.3。 你能帮帮我吗?

我会回答我自己的问题,也许对某人有用。这是一个 Vagrant 错误,修复如下:

Github link

编辑

对于那些需要一些细节的人:我是 运行 Vagrant 1.7.2 和 VirtualBox 4.3.28。 我为解决问题所做的是编辑文件

# Lines 495-510 - C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-1.7.2\plugins\providers\virtualbox\driver\version_4_3.rb
def share_folders(folders)
  folders.each do |folder|
    args = ["--name",
      folder[:name],
      "--hostpath",
-       folder[:hostpath]]
+      '\\?\' + folder[:hostpath].gsub(/[\/\]/,'\')]
    args << "--transient" if folder.key?(:transient) && folder[:transient]

    # Enable symlinks on the shared folder
    execute("setextradata", @uuid, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/#{folder[:name]}", "1")

    # Add the shared folder
    execute("sharedfolder", "add", @uuid, *args)
  end
end

如凯尔特评论所示(HERE link)。