【问题标题】:npm install within Vagrant box在 Vagrant 框中安装 npm
【发布时间】:2015-04-29 14:53:37
【问题描述】:

我有一个相当普通的 Vagrant 盒子,使用安装了 Node 的 Puphpet 配置。

但是,当我 ssh 进入该框并尝试 npm install 时,我似乎遇到了大量权限问题。

即使使用 sudo 运行似乎也不起作用

遇到

npm ERR! tar.unpack untar error /home/vagrant/.npm/gulp-autoprefixer/2.1.0/package.tgz
npm ERR! tar.unpack untar error /home/vagrant/.npm/gulp-concat/2.5.2/package.tgz
npm ERR! tar.unpack untar error /home/vagrant/.npm/gulp-livereload/3.8.0/package.tgz
npm ERR! tar.unpack untar error /home/vagrant/.npm/path/0.11.14/package.tgz
npm ERR! tar.unpack untar error /home/vagrant/.npm/gulp-notify/2.2.0/package.tgz
npm ERR! tar.unpack untar error /home/vagrant/.npm/gulp-compass/2.0.3/package.tgz
npm ERR! tar.unpack untar error /home/vagrant/.npm/gulp-minify-css/0.4.6/package.tgz
npm ERR! tar.unpack untar error /home/vagrant/.npm/gulp-plumber/0.6.6/package.tgz
npm ERR! tar.unpack untar error /home/vagrant/.npm/gulp-rename/1.2.0/package.tgz
npm ERR! tar.unpack untar error /home/vagrant/.npm/gulp/3.8.11/package.tgz
npm ERR! tar.unpack untar error /home/vagrant/.npm/gulp-uglify/1.1.0/package.tgz
npm ERR! Linux 3.13.0-32-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v0.12.0
npm ERR! npm  v2.5.1
npm ERR! path /var/www/node_modules/gulp-autoprefixer/package.json
npm ERR! code EPERM
npm ERR! errno -1

npm ERR! Error: EPERM, chown '/var/www/node_modules/gulp-autoprefixer/package.json'
npm ERR!     at Error (native)
npm ERR!  { [Error: EPERM, chown '/var/www/node_modules/gulp-autoprefixer/package.json']
npm ERR!   errno: -1,
npm ERR!   code: 'EPERM',
npm ERR!   path: '/var/www/node_modules/gulp-autoprefixer/package.json',
npm ERR!   fstream_finish_call: 'chown',
npm ERR!   fstream_type: 'File',
npm ERR!   fstream_path: '/var/www/node_modules/gulp-autoprefixer/package.json',
npm ERR!   fstream_class: 'FileWriter',
npm ERR!   fstream_stack:
npm ERR!    [ '/usr/local/lib/node_modules/npm/node_modules/fstream/lib/writer.js:308:19',
npm ERR!      '/usr/local/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:143:7',
npm ERR!      'FSReqWrap.oncomplete (evalmachine.<anonymous>:99:15)' ] }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     /var/www/npm-debug.log

我已阅读有关写入共享文件夹的信息并尝试向 Vagrantfile 添加修复但没有成功

      virtualbox.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]

有什么想法吗?

【问题讨论】:

    标签: node.js vagrant puppet


    【解决方案1】:

    原来这是 Puphpet 配置的错误,就像 https://github.com/puphpet/puphpet/issues/1378

    修复程序可以在https://github.com/puphpet/puphpet/pull/1403 中找到 - 只需替换我的 Vagrantfile 中的那个 sn-p 就可以了。我现在可以 npm 安装、捆绑安装等。

    【讨论】:

      【解决方案2】:

      您使用的是 Windows 吗?您不仅需要自定义虚拟机,还需要在您拥有提升的权限(即以管理员身份运行)时启动虚拟机。总的来说,这是一个复杂的混乱。

      如果我在我的共享文件夹中处理需要符号链接的东西(例如 npm),我已经开始使用rsync folders。使用 rsync,/vagrant 文件夹不再是 Virtual Box 共享文件夹,表示符号链接也没有问题。作为一个额外的好处,它也更快。

      【讨论】:

      • 我不是,我按照推荐在 Mac 上运行 NFS,因为我相信它的性能更高。
      • 在所有选项中,rsync 将是最快的。不幸的是,我对 Mac 无能为力!
      • 我试一试,无论如何我们都需要为 Windows 用户运行这个盒子,尽管我们现在有另一个问题
      • 谢谢克里斯。我会检查一下,因为我们也需要 Windows 开发人员。
      • 因此,如果我使用 Puphpet 中的默认共享文件夹选项 - npm install 并且我的 gulp 任务写得很好。如果我使用 NFS 或 rsync,写入失败。
      猜你喜欢
      • 1970-01-01
      • 2014-01-09
      • 1970-01-01
      • 1970-01-01
      • 2015-10-05
      • 2016-01-29
      • 1970-01-01
      • 1970-01-01
      • 2016-01-15
      相关资源
      最近更新 更多