目标
npm.xxx.com 安装和推送nodejs包
npmui.xxx.com 管理已经推送的nodejs包
 
安装 couchdb
 
https://launchpad.net/~couchdb/+archive/ubuntu/stable
 
里面有 14.10  14.04 和 12.04的   PPA地址 安装不在这里讨论
 
安装 couchdb 1.6.1
 
1.初始化
 
访问“http://localhost:5984/_utils/”
新建名字为  registry 库
 
异步 同步官方nodejs模块 (可以不做)
npm curl -X POST http://127.0.0.1:5984/_replicate -d '{"source":"http://registry.npmjs.org/registry/", "target":"registry", "continuous":true, "create_target":true}' -H "Content-Type: application/json"
2.修改配置
/usr/local/etc/couchdb/local.ini

[couch_httpd_auth]
public_fields = appdotnet, avatar, avatarMedium, avatarLarge, date, email, fields, freenode, fullname, github, homepage, name, roles, twitter, type, _id, _rev
users_db_public = true
[httpd]
bind_address = 0.0.0.0
secure_rewrites = false
[couchdb]
delayed_commits = false
[admins]
admin = password
3.上传npm程序
git clone git://github.com/npm/npm-registry-couchapp
cd npm-registry-couchapp
sudo npm install -g couchapp
npm install
npm start --npm-registry-couchapp:couch=http://admin:password@localhost:5984/registry
npm run load --npm-registry-couchapp:couch=http://admin:password@localhost:5984/registry
npm run copy --npm-registry-couchapp:couch=http://admin:password@localhost:5984/registry
couchapp push www/app.js http://admin:password@localhost:5984/registry
这边推上去的两个程序访问地址:

http://localhost:5984/_utils/registry/_design/app/_rewrite

http://localhost:5984/_utils/registry/_design/ui/_rewrite

然后只需将registry指向couchdb即可操作私有npm库:

npm --registry http://localhost:5984/registry/_design/app/_rewrite login
npm --registry http://localhost:5984/registry/_design/app/_rewrite publish my-repo

私有npm到这里就建好了,链接好长!

于是在/usr/local/etc/couchdb/default.ini文件中添加:

[vhosts]
127.0.0.1:5984=/registry/_design/app/_rewrite
127.0.0.2:5984=/registry/_design/ui/_rewrite

这回我们可以用http://127.0.0.1:5984来代替那串长长的链接了

接着就是将私有npm库没有的模块(返回404)通过npmjs.org找,于是写nginx配置如下:

server {
listen 80;
server_name npm.XXX.com;
location / {
proxy_set_header Host 127.0.0.1:5984;
proxy_pass http://127.0.0.1:5984;
proxy_intercept_errors on;
error_page 404 = @fallback;
} location @fallback{
internal;
proxy_set_header Host registry.npmjs.org;
proxy_pass http://registry.npmjs.org;
}
}
server {
listen 80;
server_name npmui.XXX.com;
location / {
proxy_set_header Host 127.0.0.2:5984;
proxy_pass http://127.0.0.2:5984;
}
}
 
写在最后
到这里我们的私有库已经搭建完成了
我们可以在 ~/.npmrc 中添加
 
registry=http://npm.XXX.com/

就可以使用我们的私有库了

npm login
#登录 admin password
#进入我们的私有包目录 完善package.json 然后
npm publish
#删除的话是
npm unpublish ***@0.0.0

ubuntu npm 私有库搭建 (npmjs.org 官方版本)的更多相关文章

  1. 使用npm私有服务器保存公司内部强业务类型组件(一):npm私有服务器搭建

    1:安装centOS虚拟机 2:安装完成虚拟机后完成后开启系统网卡: 进入到/etc/sysconfig/network-scprits/ 打开ifcfg-ens33文件 找到 ONBOOT=NO 改 ...

  2. maven私有库搭建

    一.在企业中基本上都会有自己的maven私有库,主要的目的就是方便依赖包的下载.如果采用远程的方式来实现的话,很多时候会考虑网速问题.如果自己活着公司搭建的私有库,这一样在使用上面会效率更高. 二.私 ...

  3. [k8s]helm原理&私有库搭建&monocularui和kubeapp探究

    运行最简单的charts示例 helm的2个chart例子: https://github.com/kubernetes/helm/tree/master/docs/examples/nginx he ...

  4. docker私有库搭建过程(Registry)

    实验环境: CentOS7 1611 Docker 1.12.6 registry   2.0 1.安装并运行registry 安装: [root@docker01 ~]# docker pull r ...

  5. 使用verdaccio+docker搭建npm私有仓库以及使用

    公司内部前端组件或库的共享等,搭建一个npm私有库就很方便,现在中大型公司也基本都有自己的npm私有库,这篇文章,和大家一起共同搭建一个npm私有库,共同学习 前置条件 一台电脑 可以联网 一.安装d ...

  6. 使用 docker + verdaccio 搭建npm私有仓库

    本文介绍如何使用 verdaccio 搭建私有npm仓库,以及使用 docker 时如何映射到本地目录,方便简单对仓库进行各种操作.系统环境是 Linux. verdaccio verdaccio 是 ...

  7. 远程私有库的创建 pod 组件化

    参考:   http://www.cnblogs.com/hs-funky/p/6780203.html http://www.jianshu.com/p/4b63dfbd8be7 http://ww ...

  8. 使用verdaccio 搭建npm私有仓库

    使用verdaccio 搭建npm私有仓库 1. 为什么要搭建私有的npm仓库?    随着公司的业务越来越复杂,项目迭代速度也越来越快,那么项目间的常用的业务代码共享变得非常之有必要.但是对于公司的 ...

  9. ndoe.js 和npm私有仓库的搭建

    下载nodejs的压缩包 网址:https://nodejs.org/en/ 下载以tar.xz结尾的包例如:node-v8.9.4-linux-x64.tar.xz 上传包到制定的目录 可以用lrz ...

随机推荐

  1. Yii框架tips(转)

    yii的一些小的技巧 http://www.yiichina.com/topic/151 db组件 'schemaCachingDuration'=>3600, 为什么不起做用?需要开缓存 如何 ...

  2. [置顶] shell变量赋值-linux

    Shell变量赋值 命名须规则: 1)使用变量无需事先声明 2)首个字符必须为字母(a-z,A-Z) 3)中间不能有空格,可以使用下划线(_) 4)不能使用标点符号 5)不能使用bash里的关键字(可 ...

  3. JAVA命名、注释规范

    一.命名规范 1. 项目名全部小写 2. 包名全部小写(除非部分是缩写) 3. 类名首字母大写,如果类名由多个单词组成,每个单词的首字母都要大写. 如:public class MyFirstClas ...

  4. Java中的Stringbuffer类解析

    StringBuffer类和String一样,也用来代表字符串,只是由于StringBuffer的内部实现方式和String不同,所以StringBuffer在进行字符串处理时,不生成新的对象,在内存 ...

  5. mvn开发可执行的java程序

    1.  用maven-assembly-plugin插件 2. 在项目的pom文件中加入以下该插件的配置 <span style="font-size:18px;">& ...

  6. android 66 sharedperference的使用

    package com.itheima.qqlogin; import java.io.BufferedReader; import java.io.File; import java.io.File ...

  7. j2ee学习笔记 Filter过滤器

    作用:过滤response和request对象的内容 使用: Filter是J2EE的一个接口,自定义Filter需要实现该接口,并重写所有的方法. Filter提供的方法: init() doFil ...

  8. 高效 jquery 的奥秘

    当你准备使用 jQuery,我强烈建议你遵循下面这些指南: 1. 缓存变量 DOM 遍历是昂贵的,所以尽量将会重用的元素缓存. // 糟糕 h = $('#element').height(); $( ...

  9. iOS开发中常用的手势---边缘手势

    说明:以下方法是开发中使用的方法,有什么不对的或者好的方法,请多多指教! 此处的边缘手势是用来控制左侧抽屉视图的弹出以及收回. 添加手势 : 页面上有多个手势时需要遵循 UIGestureRecogn ...

  10. C#中的两种debug方法

    这篇文章主要介绍了C#中的两种debug方法介绍,本文讲解了代码用 #if DEBUG 包裹.利用宏定义两种方法,需要的朋友可以参考下   第一种:需要把调试方法改成debug代码用 #if DEBU ...