npm 无法安装量角器或 selenium-webdriver -> gyp ERR!构建错误

npm cannot install protractor or selenium-webdriver -> gyp ERR! build error

对于一个 Angular 项目,我写了一些 E2E 测试,我想测试它们,但我无法安装量角器或 selenium-webdriver,我收到错误消息:

gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:269:23)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
gyp ERR! System Linux 3.19.0-26-generic
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/node_modules/ws/node_modules/utf-8-validate
gyp ERR! node -v v0.12.4
gyp ERR! node-gyp -v v2.0.2
gyp ERR! not ok 

我已经在 Whosebug 和 github 上搜索了这个错误,但还没有接近解决这个错误。

我在 Ubuntu 15.04 上使用 npm -v 2.14.0。满足 gyp 依赖项:Python 2.7.9,make 和 gcc 版本 4.9.2 (Ubuntu 4.9.2-10ubuntu13)

此处粘贴了 npm install protractor 的完整输出:http://pastebin.com/yz2z0Cnh

阅读 后,我尝试了这三个命令:

$ npm cache clean
$ rm -rf node_modules
$ rm -rf ~/.node-gyp

之后能够 npm install -g protractor 所以我自己找到了答案。