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

Installing github hosted npm dependencies with Docker

我正在尝试对一个项目进行 docker 化,但是我在 npm install 过程中遇到了我的 Gulp 4 依赖项的问题。我使用 Gulp 4 是因为我们需要一些新功能,但我所看到的有关使用 Gulp 4 预发布版本的所有说明都是使用 github 分支 url。这是有问题的依赖项:

"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

这是我目前正在使用的Docker文件:

# 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 url 兼容?或者是否有另一种方法来包含 Docker 会满意的依赖项?

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

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