如何在Travis-CI下的Ubuntu 14上安装npm

时间:2017-03-27 22:40:50

标签: node.js ubuntu travis-ci

我正在尝试在Travis-CI下运行的Ubuntu 14上安装npm包。

它在我当地的Ubuntu 14安装上安装得很好,但是在Travis上,它失败并出现错误:

[127.0.0.1] out: dpkg: error processing archive /var/cache/apt/archives/npm_1.3.10~dfsg-1_all.deb (--unpack):
[127.0.0.1] out:  trying to overwrite '/usr/bin/npm', which is also in package nodejs 0.12.7-rwky1~trusty
[127.0.0.1] out: Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
[127.0.0.1] out: Errors were encountered while processing:
[127.0.0.1] out:  /var/cache/apt/archives/npm_1.3.10~dfsg-1_all.deb
[127.0.0.1] out: E: Sub-process /usr/bin/dpkg returned an error code (1)
[127.0.0.1] out: 
Fatal error: sudo() received nonzero return code 100 while executing!
Requested: apt-get update --fix-missing; DEBIAN_FRONTEND=noninteractive apt-get install --yes npm
Executed: sudo -S -p 'sudo password:'  /bin/bash -l -c "apt-get update --fix-missing; DEBIAN_FRONTEND=noninteractive apt-get install --yes npm"

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题并通过尝试安装.travis.yml软件包解决了这个问题。

在我的情况下,我使用trusty ci environment on Travis并认为它来了pre-installed with nodejs(因此,npm - 我认为)。所以,从我的repo的npm文件中,我只是删除了我尝试安装的行- sudo apt-get install -y npm (在我的情况下:before_install在{在npm install文件执行的npm部分中使用install和其他.travis.yml用法等命令{1}}部分并且构建已通过成功。

我希望有所帮助!