赞
踩
报错信息如下:
Step 6/11 : RUN npm install
---> Running in fbea7757df0b
npm WARN ub-arc-mgmt@4.2.1 license should be a valid SPDX license expression
npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t git://github.com/adobe-webplatform/eve.git
npm ERR!
npm ERR! fatal: unable to connect to github.com:
npm ERR! github.com[0: 52.74.223.119]: errno=Connection timed out
npm ERR!
npm ERR!
npm ERR! exited with error code: 128
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-02-27T09_03_17_432Z-debug.log
场景:
在用docker 构建vue node项目镜像时,执行npm install 命令是包连接不上github.com
网上搜索到解决方案:
参考:
引用上文的解释:
意思是我连接不上github。但是不可能啊,我能够访问github的官网。而且在其他工程里执行npm install都能很顺利执行完成了。看来很有可能是上面截图中eve.git这个库的引用防止有些不太一致造成的。于是在通过在网络上搜寻,找到了原因所在:
上图中可以看到这个eve.git这个库的引用是通过git写引用的。git协议的默认端口是9418,很有可能是我的网络环境防火墙并没有开放这个端口造成的。解决方法就是,用https替代git协议。配置的命令为:
git config --global url."https://".insteadOf git://
在Dockerfile中执行npm install之前,执行上述命令
修改如下:
- //解决npn install报错连接不上git的问题。
- RUN git config --global url."https://".insteadOf git://
- RUN npm install
后续npm install问题接龙:
1、npm ERR! Failed at the node-sass@4.13.0 postinstall script.
- gyp ERR! build error
- gyp ERR! stack Error: `make` failed with exit code: 2
- gyp ERR! stack at ChildProcess.onExit (/home/erms/uicode/ub-arc-mgmt-gui/node_modules/node-gyp/lib/build.js:262:23)
- gyp ERR! stack at ChildProcess.emit (events.js:210:5)
- gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
- gyp ERR! System Linux 3.10.0-693.el7.x86_64
- gyp ERR! command "/root/.nvm/versions/node/v12.13.1/bin/node" "/home/erms/uicode/ub-arc-mgmt-gui/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
- gyp ERR! cwd /home/erms/uicode/ub-arc-mgmt-gui/node_modules/node-sass
- gyp ERR! node -v v12.13.1
- gyp ERR! node-gyp -v v3.8.0
- gyp ERR! not ok
- Build failed with error code: 1
- npm WARN ub-arc-mgmt@4.2.1 license should be a valid SPDX license expression
- npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/fsevents):
- npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
-
- npm ERR! code ELIFECYCLE
- npm ERR! errno 1
- npm ERR! node-sass@4.13.0 postinstall: `node scripts/build.js`
- npm ERR! Exit status 1
- npm ERR!
- npm ERR! Failed at the node-sass@4.13.0 postinstall script.
- npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
-
- npm ERR! A complete log of this run can be found in:
- npm ERR! /root/.npm/_logs/2020-03-01T12_04_15_682Z-debug.log
解决:
这个是因为sass安装时获取源的问题,先修改sass安装的源,再运行npm install
就成功了
npm config set sass_binary_site=https://npm.taobao.org/mirrors/node-sass
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。