有一个包含以下
package.json
文件的项目:{ "name": "requirejs-library-skeleton", "description": "RequireJS skeleton for modern JS libraries.", "version": "0.2.0", "homepage": "http://github.com/tkellen/requirejs-library-skeleton", "author": "Tyler Kellen", "engines": { "node": ">=0.6.0" }, "scripts": { "test": "grunt test" }, "devDependencies": { "grunt": "~0.4", "grunt-contrib-watch": "*", "grunt-contrib-less": "~0.6.1", "grunt-contrib-requirejs": "~0.3.2", "grunt-contrib-jasmine": "~0.4.0", "grunt-template-jasmine-requirejs": "*", "grunt-contrib-connect": "~0.1.0", "grunt-file-creator": "*", "clean-pattern": "*", "grunt-concat-css": "*", "grunt-phpcs": "*", "grunt-phplint": "*", "grunt-phpunit": "*", "grunt-exec": "*" } }
具有以下
Vagrantfile
配置:Vagrant.configure("2") do |config| config.vm.box = "precise32" config.vm.box_url = "http://files.vagrantup.com/precise32.box" config.vm.provision :shell, :path => "bootstrap/bootstrap.sh" # ... other stuff like opening ports ... end
bootstrap.sh
最有趣的是,看起来像这样:#!/usr/bin/env bash # Installing prequisites for adding nodejs repository apt-get update apt-get install -y python-software-properties python g++ make # Adding Nodejs specific repository add-apt-repository -y ppa:chris-lea/node.js # Installing other software # ... apt-get invocations ... # Installing grunt harness npm install -g grunt-cli # Other preparation tasks # ... setting up DB, runtime directories, generating configs, etc. # Moving to codebase root now cd /vagrant # Disguising ourselves as normal user (hack 1) su vagrant # Cleaning the NPM cache (hack 2) npm cache clean # Installing nodejs prequisites npm install # Rebuilding codebase (I have to run it after EVERY change in configuration, CSS and/or JS files). grunt # Other post-deploy application-specific things # ... echo "All should be done\n";
在调用时
npm install
它会失败并出现以下随机错误:npm http GET https://registry.npmjs.org/lodash/-/lodash-1.0.1.tgz npm ERR! Error: ENOENT, lstat '/vagrant/node_modules/grunt-contrib-jasmine/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/node_modules/adm-zip/.travis.yml' npm ERR! If you need help, you may report this log at: npm ERR! <http://github.com/isaacs/npm/issues> npm ERR! or email it to: npm ERR! <[email protected]> npm ERR! System Linux 3.2.0-23-generic-pae npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" npm ERR! cwd /vagrant npm ERR! node -v v0.10.22 npm ERR! npm -v 1.3.14 npm ERR! path /vagrant/node_modules/grunt-contrib-jasmine/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/node_modules/adm-zip/.travis.yml npm ERR! fstream_path /vagrant/node_modules/grunt-contrib-jasmine/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/node_modules/adm-zip/.travis.yml npm ERR! fstream_type File npm ERR! fstream_class FileWriter npm ERR! code ENOENT npm ERR! errno 34 npm ERR! fstream_stack /usr/lib/node_modules/npm/node_modules/fstream/lib/writer.js:284:26 npm ERR! fstream_stack Object.oncomplete (fs.js:107:15) npm ERR! Error: ENOENT, lstat '/vagrant/node_modules/grunt-contrib-jasmine/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/node_modules/mkdirp/test/mkdirp.js' npm ERR! If you need help, you may report this log at: npm ERR! <http://github.com/isaacs/npm/issues> npm ERR! or email it to: npm ERR! <[email protected]> npm ERR! System Linux 3.2.0-23-generic-pae npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" npm ERR! cwd /vagrant npm ERR! node -v v0.10.22 npm ERR! npm -v 1.3.14 npm ERR! path /vagrant/node_modules/grunt-contrib-jasmine/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/node_modules/mkdirp/test/mkdirp.js npm ERR! fstream_path /vagrant/node_modules/grunt-contrib-jasmine/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/node_modules/mkdirp/test/mkdirp.js npm ERR! fstream_type File npm ERR! fstream_class FileWriter npm ERR! code ENOENT npm ERR! errno 34 npm ERR! fstream_stack /usr/lib/node_modules/npm/node_modules/fstream/lib/writer.js:284:26 npm ERR! fstream_stack Object.oncomplete (fs.js:107:15) npm ERR! EEXIST, mkdir '/vagrant/node_modules/grunt-contrib-jasmine/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/node_modules/npmconf/test' File exists: /vagrant/node_modules/grunt-contrib-jasmine/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/node_modules/npmconf/test Move it away, and try again. npm ERR! System Linux 3.2.0-23-generic-pae npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" npm ERR! cwd /vagrant npm ERR! node -v v0.10.22 npm ERR! npm -v 1.3.14 npm ERR! path /vagrant/node_modules/grunt-contrib-jasmine/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/node_modules/npmconf/test npm ERR! fstream_path /vagrant/node_modules/grunt-contrib-jasmine/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/node_modules/npmconf/test/builtin.js npm ERR! fstream_type File npm ERR! fstream_class FileWriter npm ERR! code EEXIST npm ERR! errno 47 npm ERR! fstream_stack /usr/lib/node_modules/npm/node_modules/fstream/lib/writer.js:171:23 npm ERR! fstream_stack /usr/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53 npm ERR! fstream_stack Object.oncomplete (fs.js:107:15) npm ERR! Error: ENOENT, lstat '/vagrant/node_modules/grunt-contrib-jasmine/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/node_modules/kew/test/context.js' npm ERR! If you need help, you may report this log at: npm ERR! <http://github.com/isaacs/npm/issues> npm ERR! or email it to: npm ERR! <[email protected]> npm ERR! System Linux 3.2.0-23-generic-pae npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" npm ERR! cwd /vagrant npm ERR! node -v v0.10.22 npm ERR! npm -v 1.3.14 npm ERR! path /vagrant/node_modules/grunt-contrib-jasmine/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/node_modules/kew/test/context.js npm ERR! fstream_path /vagrant/node_modules/grunt-contrib-jasmine/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/node_modules/kew/test/context.js npm ERR! fstream_type File npm ERR! fstream_class FileWriter npm ERR! code ENOENT npm ERR! errno 34 npm ERR! fstream_stack /usr/lib/node_modules/npm/node_modules/fstream/lib/writer.js:284:26 npm ERR! fstream_stack Object.oncomplete (fs.js:107:15) npm ERR! EEXIST, mkdir '/vagrant/node_modules/grunt-contrib-jasmine/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/node_modules/ncp/test/fixtures/src' File exists: /vagrant/node_modules/grunt-contrib-jasmine/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/node_modules/ncp/test/fixtures/src Move it away, and try again. npm ERR! System Linux 3.2.0-23-generic-pae npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" npm ERR! cwd /vagrant npm ERR! node -v v0.10.22 npm ERR! npm -v 1.3.14 npm ERR! path /vagrant/node_modules/grunt-contrib-jasmine/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/node_modules/ncp/test/fixtures/src npm ERR! fstream_path /vagrant/node_modules/grunt-contrib-jasmine/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/node_modules/ncp/test/fixtures/src/d npm ERR! fstream_type File npm ERR! fstream_class FileWriter npm ERR! code EEXIST npm ERR! errno 47 npm ERR! fstream_stack /usr/lib/node_modules/npm/node_modules/fstream/lib/writer.js:171:23 npm ERR! fstream_stack /usr/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53 npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
这到底发生什么事了?
如果我执行vagrant ssh
并运行cd /vagrant; npm install
,npm 运行没有任何问题!
答案1
好的,我在这里找到了解决方案:https://askubuntu.com/questions/269727/npm-errors-when-installing-packages-on-windows-share
我只需要使用npm install --no-bin-links
。很高兴能得到答案为什么。