美文网首页
Deploy a private npm registry in

Deploy a private npm registry in

作者: igor_d140 | 来源:发表于2019-03-08 18:29 被阅读0次

    Deploy a private npm registry in 5 minutes

    EditNew Page

    ChangchengQin edited this page <relative-time datetime="2018-03-22T14:02:02Z" title="Mar 22, 2018, 10:02 PM GMT+8" style="box-sizing: border-box;">on Mar 22, 2018</relative-time> · 18 revisions

    Requires

    • Node.js >= 4.2.3
    • Linux or OSX

    Install cnpmjs.org and cnpm from npm

    $ npm install -g --build-from-source cnpmjs.org cnpm sqlite3
    

    If you're in China, maybe you should use China mirror

    $ npm install -g --build-from-source \
      --registry=https://registry.npm.taobao.org \
      --disturl=https://npm.taobao.org/mirrors/node \
      cnpmjs.org cnpm sqlite3
    

    Start cnpmjs.org server with configs

    • admins: myname,othername
    • scopes: my-company-name,other-name
    • default ports: 7001-registry, 7002-web
    $ nohup cnpmjs.org start --admins='admin,sensecare' \
      --scopes='@sensetime,@senseui' &
    

    Change cnpm default registry to your private registry

    $ cnpm set registry http://localhost:7001
    

    Use cnpm to login yourself on your private registry

    $ cnpm login
    Username: myname
    Password: ***
    Email: (this IS public) m@fengmk2.com
    

    Publish your private package now!

    Private package should be a scoped package

    $ cd /tmp
    $ mkdir helloworld && cd helloworld
    $ cnpm init
    name: (helloworld) @my-company-name/helloworld
    version: (1.0.0)
    
    {
      "name": "@my-company-name/helloworld",
      "version": "1.0.0",
      "description": "my first scoped package",
      "main": "index.js",
      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1"
      },
      "author": "",
      "license": "ISC"
    }
    
    $ cnpm publish
    + @my-company-name/helloworld@1.0.0
    

    View your private package

    You can visit with bowsers

    $ open http://localhost:7002/@my-company-name/helloworld
    

    Or use cnpm info

    $ cnpm info
    

    All public packages available directly

    You can install all public packages from npmjs.org

    $ cnpm install mocha
    

    相关文章

      网友评论

          本文标题:Deploy a private npm registry in

          本文链接:https://www.haomeiwen.com/subject/ojrdpqtx.html