使用Docker安装github托管的npm依赖项

时间:2016-05-23 18:39:39

标签: node.js github docker npm npm-install

我试图将项目停靠,但我在npm install进程中遇到了与Gulp 4相关的问题。我使用的是Gulp 4,因为我们需要一些新功能,但我使用Gulp 4的预发行版本时所看到的所有指令都是使用github分支网址。这是违规的依赖:

"gulp": "github:gulpjs/gulp#4.0",

以下是我尝试运行docker build -t user/project .时出现的错误:

npm ERR! Error: No compatible version found: gulp@'github:gulpjs/gulp#4.0'
npm ERR! Valid install targets:
npm ERR! ["0.0.1","0.0.2","0.0.3","0.0.4","0.0.5","0.0.7","0.0.8","0.0.9","0.1.0","0.2.0","1.0.0","1.1.0","1.2.0","1.2.1","2.0.0","2.0.1","2.1.0","2.2.0","2.3.0","2.4.0","2.4.1","2.6.0","2.6.1","2.7.0","3.0.0","3.1.1","3.1.2","3.1.3","3.1.4","3.2.0","3.2.1","3.2.2","3.2.3","3.2.4","3.2.5","3.3.0","3.3.1","3.3.2","3.3.4","3.4.0","3.5.0","3.5.1","3.5.2","3.5.5","3.5.6","3.6.0","3.6.1","3.6.2","3.7.0","3.8.0","3.8.1","3.8.2","3.8.3","3.8.4","3.8.5","3.8.6","3.8.7","3.8.8","3.8.9","3.8.10","3.8.11","3.9.0","3.9.1"]
npm ERR!     at installTargetsError (/usr/lib/node_modules/npm/lib/cache.js:719:10)
npm ERR!     at /usr/lib/node_modules/npm/lib/cache.js:638:10
npm ERR!     at saved (/usr/lib/node_modules/npm-registry-client/lib/get.js:148:7)
npm ERR!     at /usr/lib/node_modules/graceful-fs/polyfills.js:133:7
npm ERR!     at Object.oncomplete (fs.js:108:15)
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <npm-@googlegroups.com>

npm ERR! System Linux 3.19.0-51-generic
npm ERR! command "node" "/usr/bin/npm" "install"
npm ERR! cwd /src
npm ERR! node -v v0.10.42
npm ERR! npm -v 1.3.6

这是我目前使用的Dockerfile:

# Using CentOS
FROM    centos:centos6

# Enable Extra Packages for Enterprise Linux (EPEL) for CentOS
RUN     yum install -y epel-release

# Install Node.js and npm
RUN     yum install -y nodejs npm
COPY    package.json /src/package.json

# Install app dependencies
RUN     cd /src; npm install

# Bundle app source
COPY    . /src

# Run server
EXPOSE  8080
CMD     ["npm", "start"]

有没有办法让Docker与github网址一致?或者是否有另一种方法来包含Docker对它的满意度?

1 个答案:

答案 0 :(得分:1)

问题是由基本映像上可用的旧版本节点引起的。 节点版本与gulp版本不兼容。

具有较新版本节点的基本映像解决了该问题。