V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
noobsheldon
V2EX  ›  Docker

docker 中的 npm 修改源怎么修改啊?

  •  
  •   noobsheldon · 2017-02-25 21:10:23 +08:00 · 6172 次点击
    这是一个创建于 2822 天前的主题,其中的信息可能已经有所发展或是发生改变。

    如何能在下面 build 时使用国内镜像啊?我在 Dockerfile 中试过添加如下几行依然无效:

    
    RUN npm set registry https://registry.npm.taobao.org
    RUN npm config set registry https://registry.npm.taobao.org
    RUN npm config set disturl https://npm.taobao.org/dist
    

    Dockerfile

    
    FROM node:5-onbuild
    RUN npm install webpack babel-cli local-web-server --global && webpack --config webpack.production.config.js
    

    build 时,输出为如下内容=====================================

    
    Step 1/1 : COPY package.json /usr/src/app/
     ---> Using cache
    Step 1/1 : RUN npm install
     ---> Running in fb7fe947bc51
    npm info it worked if it ends with ok
    npm info using [email protected]
    npm info using [email protected]
    npm info attempt registry request try #1 at 11:47:54 AM
    npm http request GET https://registry.npmjs.org/bootstrap
    npm info attempt registry request try #1 at 11:47:54 AM
    npm http request GET https://registry.npmjs.org/classnames
    npm info attempt registry request try #1 at 11:47:54 AM
    npm http request GET https://registry.npmjs.org/file-loader
    npm info attempt registry request try #1 at 11:47:54 AM
    npm http request GET https://registry.npmjs.org/foundation-sites
    npm info attempt registry request try #1 at 11:47:54 AM
    npm http request GET https://registry.npmjs.org/isomorphic-fetch
    npm info attempt registry request try #1 at 11:47:54 AM
    npm http request GET https://registry.npmjs.org/jquery
    npm info attempt registry request try #1 at 11:47:54 AM
    npm http request GET https://registry.npmjs.org/jwt-decode
    npm info attempt registry request try #1 at 11:47:54 AM
    npm http request GET https://registry.npmjs.org/react
    npm info attempt registry request try #1 at 11:47:54 AM
    npm http request GET https://registry.npmjs.org/react-dom
    npm info attempt registry request try #1 at 11:47:54 AM
    npm http request GET https://registry.npmjs.org/react-hot-loader
    npm info attempt registry request try #1 at 11:47:54 AM
    npm http request GET https://registry.npmjs.org/react-iframe
    npm info attempt registry request try #1 at 11:47:54 AM
    npm http request GET https://registry.npmjs.org/react-redux
    npm info attempt registry request try #1 at 11:47:54 AM
    npm http request GET https://registry.npmjs.org/react-router
    npm info attempt registry request try #1 at 11:47:54 AM
    npm http request GET https://registry.npmjs.org/react-router-redux
    npm info attempt registry request try #1 at 11:47:54 AM
    npm http request GET https://registry.npmjs.org/redux
    npm info attempt registry request try #1 at 11:47:54 AM
    npm http request GET https://registry.npmjs.org/redux-auth-wrapper
    npm info attempt registry request try #1 at 11:47:54 AM
    npm http request GET https://registry.npmjs.org/redux-form
    
    4 条回复    2017-03-15 18:50:16 +08:00
    chairuosen
        1
    chairuosen  
       2017-02-25 21:17:38 +08:00
    npm install --registry=https://registry.npm.taobao.org xxxxx
    noobsheldon
        2
    noobsheldon  
    OP
       2017-02-25 21:23:27 +08:00
    @chairuosen 输出还是一样的。。。
    credochen
        3
    credochen  
       2017-02-26 09:18:42 +08:00 via iPhone
    用 cnpm 。
    darrenfang
        4
    darrenfang  
       2017-03-15 18:50:16 +08:00 via iPhone
    npm install cnpm --registry=https://registry.npm.taobao.org

    cnpm install
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   3216 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 12:25 · PVG 20:25 · LAX 04:25 · JFK 07:25
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.