解决mac下atom安装插件失败问题

activate-power-mode的超炫编辑效果打动了我,花时间安装了atom,之后在package,install里面找到了这个插件,但是安装失败,如下图所示:

gyp info it worked if it ends with ok
gyp info using node-gyp@2.0.2
gyp info using node@0.10.40 | darwin | x64
gyp http GET https://atom.io/download/atom-shell/v0.34.3/node-v0.34.3.tar.gz
gyp WARN install got an error, rolling back install
gyp ERR! install error 
gyp ERR! stack Error: socket hang up
gyp ERR! stack     at createHangUpError (http.js:1473:15)
gyp ERR! stack     at Socket.socketOnEnd (http.js:1569:23)
gyp ERR! stack     at Socket.g (events.js:180:16)
gyp ERR! stack     at Socket.emit (events.js:117:20)
gyp ERR! stack     at _stream_readable.js:944:16
gyp ERR! stack     at process._tickCallback (node.js:448:13)
gyp ERR! System Darwin 14.5.0
gyp ERR! command "/Applications/Atom.app/Contents/Resources/app/apm/bin/node" "/Applications/Atom.app/Contents/Resources/app/apm/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "install" "--target=0.34.3" "--dist-url=https://atom.io/download/atom-shell" "--arch=x64" "--ensure"
gyp ERR! cwd /Users/luozhifan/.atom
gyp ERR! node -v v0.10.40
gyp ERR! node-gyp -v v2.0.2
gyp ERR! not ok 

用了公司的vpn,网络肯定没问题,看来是atom的下载模块有问题,于是做了如下操作,问题顺利解决:

1, 用chrome下载该文件,同时把同目录下的SHASUMS256.txt也下载下来,放置在同一目录里面,目录起名v0.34.3,

https://atom.io/download/atom-shell/v0.34.3/node-v0.34.3.tar.gz 
https://atom.io/download/atom-shell/v0.34.3/SHASUMS256.txt

2, 上一级目录,执行命令 sudo python -m SimpleHTTPServer 80,  启动web server,替换node的升级下载服务器

3,将出错信息中的命令行复制出来,修改dist-url参数后,在控制台中执行,完成node升级。

"/Applications/Atom.app/Contents/Resources/app/apm/bin/node" "/Applications/Atom.app/Contents/Resources/app/apm/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "install" "--target=0.34.3" "--dist-url=http://localhost" "--arch=x64" "--ensure"

4,修改

/Applications/Atom.app/Contents/Resources/app/apm/node_modules/npm/node_modules/node-gyp/lib/install.js

在go()函数入口168行添加:

    //todo: lzf skip node update

    cb()

    return

跳过node升级过程,改动完成。


其他三步如果不能成功完成,则修改最后一步,或许也可以成功噢