在Vagrant环境中安装JShint时出错

时间:2015-05-06 01:57:25

标签: vagrant jshint

大家好日子:

通过我的Vagrant环境安装JShint和CSS Linter时遇到了这些错误。我在Windows中使用Vagrant,Ubuntu在我的流浪盒上。

我已经安装了npm和nodejs,尝试了很多更新但没有运气。

也许其他人可以发光。

这是错误。

vagrant@precise32:~$ npm install jshint

vagrant@precise32:~$ npm install jshint
npm http GET https://registry.npmjs.org/jshint

npm ERR! Error: failed to fetch from registry: jshint
npm ERR! at /usr/share/npm/lib/utils/npm-registry-client/get.js:139:12
npm ERR! at cb (/usr/share/npm/lib/utils/npm-registry-cient/request.js:31:9)
npm ERR! at Request._callback (/usr/share/npm/lib/utils/npm-registry-client/request.js:136:
npm ERR! at Request.callback (/usr/lib/nodejs/request/main.js:119:22)
npm ERR! at Request.<anonymous> (/usr/lib/nodejs/request/main.js:212:58)
npm ERR! at Request.emit (events.js:88:20)
npm ERR! at ClientRequest.<anonymous (/usr/lib/nodejs/request/main.js:412:12)
npm ERR! at ClientRequest.emit (events.js:67:17)
npm ERR! at HTTPParser.onIncoming (http.js:1261:11)
npm ERR! at HTTPParser.onHeadersComplete (http.js:102:31)
npm ERR! You may report this log at:
npm ERR! <http://bugs.debian.org/npm>
npm ERR! or use npm ERR!reportbug --attach /home/vagrant/npm-debug.log npm
npm ERR! npm ERR! System Linux 3.2.0-23-generic-pae
npm ERR! command "node" "/usr/bin/npm" "install" "jshint"
npm ERR! cwd /home/vagrant
npm ERR! node -v v0.6.12
npm ERR! npm -v 1.1.4
npm ERR! message failed to fetch from registry: jshint
npm ERR! Additional logging details can be found in:
npm ERR! /home/vagrant/npm-debug.log

npm不行

1 个答案:

答案 0 :(得分:2)

请回复您的npm --versionnode --version。我怀疑是否有数据npm / nodejs库。

在任何一种情况下,试试这个:

npm config set registry https://registry.npmjs.org/

此处已关闭错误:https://github.com/npm/npm/issues/2119

编辑:也许这是Ubuntu VM的Windows主机的问题:

https://github.com/npm/npm/issues/7308

  1. npm install jshint --no-bin-link如果安装,那么您的文件系统不支持链接,每次运行npm install时,都需要附加此标志。如果使用此标志,则无法使用npm install -g标志进行全局安装。
  2. npm可能无法检测到您的主机文件系统,因为npm是在Ubuntu VM上运行的。您需要在Vagrantfile中允许Windows主机上的符号链接:

    config.vm.provider "virtualbox" do |v|
        v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/vagrant", "1"]
    end
    
  3. 如果您想绕过设置Vagrantfile并且没有安装全局二进制文件(-g标志),我强烈建议不要这样做,那么请为您的npm install --no-bin-links设置别名:

    echo "alias npm='npm --no-bin-links'" >> /home/vagrant/.bashrc