2016-05-23 125 views
0

我正在試圖dockerize一個項目,但我在使用我的gulp 4依賴關係的npm install進程中遇到問題。我使用的是Gulp 4,因爲我們需要一些新的功能,但是我看到使用Gulp 4的預發佈版本的所有說明都是使用github分支url。這是有問題的依賴性:與Docker安裝github託管的npm依賴關係

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

這裏是我的錯誤,當我嘗試運行docker build -t user/project .

npm ERR! Error: No compatible version found: [email protected]'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!  <[email protected]> 

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 url一致?還是有另一種方法來包含Docker會滿意的依賴關係?

+1

你能在docker文件中回顯節點版本嗎?確認容器中哪個版本的節點可用? – Shibashis

+0

良好的呼叫!我愚蠢地認爲版本會有點新,但是它是0.10。用更新版本抓取碼頭依賴項修復了它。 – TimE

回答

1

該問題是由基礎映像上可用節點的舊版本引起的。 節點版本與gulp版本不兼容。

具有較新版本節點的基礎映像解決了該問題。