目标
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. 获取toast值

    /** * 获取Toast的String值 * @return */ public String getToast(int timeout){ TextView toastTextView = nul ...

  2. iOS新建项目基本配置

    项目整体同xib+代码的方式 1.调整项目文件结构 2.将资源图片导入工程 General->LaunchScreen 修改 3.App名称修改 info->Bundle name 4.删 ...

  3. 在Mybatis-spring中由于默认Autowired导致不能配置多个数据源的问题分析及解决

    在使用Mybatis中,通常使用接口来表示一个Sql Mapper的接口以及相对应的xml实现,而在spring的配置文件中,通常会使用MapperScannerConfigurer来达到批量扫描以及 ...

  4. 如何在ubuntu下使用stage3d的硬件加速

    最近想尝试一下心动的新游戏深渊,但是由于公司的电脑是ubuntu的,只要进游戏就提示说没有stage3d的硬件加速,于是google了一下,发现这么一篇文章 http://phoronix.com/f ...

  5. poj 2081 Recaman's Sequence

    開始还以为暴力做不出来,须要找规律,找了半天找不出来.原来直接暴力.. 代码例如以下: #include<stdio.h> int a[1000050]; int b[100000000] ...

  6. SQL Server与Oracle对比学习:表的管理和组织

    http://blog.csdn.net/weiwenhp/article/details/8088979 我们知道数据库,顾名思义.最重要的东东就是管理数据,而数据在系统中主要是保存在表(table ...

  7. [Javascript] IIFE

    Javascript modules are a design pattern that allow you to encapsulate your code into smaller self ma ...

  8. mybatis04 根据用户名称模糊查询用户信息

    根据用户名称模糊查询用户信息可能返回多条记录. 1.1.1User.xml 编码 如果用%进行模糊查询,#{}表示一个占位符会被翻译为一个?号(SELECT * FROM USER WHERE id= ...

  9. 追踪CPU跑满 堆栈调试

    http://blog.donghao.org/2014/04/24/%E8%BF%BD%E8%B8%AAcpu%E8%B7%91%E6%BB%A1/

  10. 使用dom4j对xml文件进行增删改查

    1.使用dom4j技术对dom_demo.xml进行增删改查 首选要下载dom4j的jar包 在官网上找不到,网上搜索了一下在这个链接:http://sourceforge.net/projects/ ...