2016-11-25 55 views
2

我想讓我的Node.js 7項目在TravisCI上工作。一切正常,在當地,但是當特拉維斯試圖測試的項目,我得到:TravisCI在節點BCrypt上出現節點gyp錯誤

gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2 
gyp ERR! stack  at ChildProcess.onExit (/home/travis/.nvm/versions/node/v6.9.1/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23) 
gyp ERR! stack  at emitTwo (events.js:106:13) 
gyp ERR! stack  at ChildProcess.emit (events.js:191:7) 
gyp ERR! stack  at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12) 
gyp ERR! System Linux 4.8.7-040807-generic 
gyp ERR! command "/home/travis/.nvm/versions/node/v6.9.1/bin/node" "/home/travis/.nvm/versions/node/v6.9.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" 
gyp ERR! cwd /home/travis/build/actuallymentor/react-node-boilerplate/node_modules/bcrypt 
gyp ERR! node -v v6.9.1 
gyp ERR! node-gyp -v v3.4.0 
gyp ERR! not ok 

和:

npm ERR! [email protected] install: `node-gyp rebuild` 
npm ERR! Exit status 1 
npm ERR! 
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'. 
npm ERR! Make sure you have the latest version of node.js and npm installed. 
npm ERR! If you do, this is most likely a problem with the bcrypt package, 
npm ERR! not with npm itself. 
npm ERR! Tell the author that this fails on your system: 
npm ERR!  node-gyp rebuild 

這將導致即使在運行測試之前,我的生成失敗。

回答

3

這裏的問題是,bcrypt需要使用C++庫。特拉維斯沒有安裝。爲了使它的工作,我們需要:

  1. 安裝庫
  2. 設置環境變量,指示我們要使用它

另外節點GYP喜歡被全球的裝機量,所以我們可以配置以及一氣呵成。

在你.travis.yml地說:

sudo: required 
before_install: 
    - npm install -g node-gyp 
addons: 
    apt: 
    sources: 
    - ubuntu-toolchain-r-test 
    packages: 
    - g++-5 

此外,一定要在你的特拉維斯項目設置中設置此環境變量:

CXX=g++-5 

注意,任何G ++版本4.8以上應該工作。

0

這個工作對我來說!

4.6.2的NodeJS,bcryp 1.0.1上特拉維斯

env: 
    - CXX=g++-4.8 
addons: 
    apt: 
    sources: 
    - ubuntu-toolchain-r-test 
    packages: 
    - g++-4.8