目标
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. advanced dom scripting dynamic web design techniques Chapter 2 CREATING YOUR OWN REUSABLE OBJECTS

    JavaScript is all about objects. Objects are the foundation of everything, so if you’re unfamiliar w ...

  2. 普通Windows控制台窗口运行nmake编译VC

    我的GDAL编译都是在VS2012提供的prompt windows里面运行nmake完成的.但是如果想将编译自动化,放到Jenkins里面怎么办呢?首先没有VS2012的工程,也不想费力去生成一个, ...

  3. UF2.0、O4、UFT、TA众明星背后的秘密

    UF2.0--经纪业务运营平台 O4--投资交易管理系统软件 UFT--证券极速交易系统软件 TA--登记过户系统 -- 说到恒生在业内的明星产品,太多了,小编一口气说不完,但小编只知其一,殊不知这些 ...

  4. mysql 加载文本数据

    可以配置导入哪几列,每个字段用什么隔开,每行用什么隔开,也可以单独设置某个字段的值. 详细看代码: LOAD DATA INFILE 'D:/aa.txt' INTO TABLE aa FIELDS ...

  5. [TypeScript] Using Lodash in TypeScript with Typings and SystemJS

    One of the most confusing parts of getting started with TypeScript is figuring out how to use all th ...

  6. android Fragments详解六:处理fragement的生命周期

    把条目添加到动作栏 你的fragment们可以向activity的菜单(按Manu键时出现的东西)添加项,同时也可向动作栏(界面中顶部的那个区域)添加条目,这都需通过实现方法onCreateOptio ...

  7. windows修改mysql默认字符集不成功

    今天下午弄了半天,终于把mysql的默认字符集弄成了, 按照网上的说法,什么修改mysql下面的my.ini文件,把参数设置成utf-8,我反复操作,结果都是不成功,后来我把mysql5.0卸载了,网 ...

  8. 深入分析 iBATIS 框架之系统架构与映射原理--转载

    http://www.ibm.com/developerworks/cn/java/j-lo-ibatis-principle/ iBATIS 通过 SQL Map 将 Java 对象映射成 SQL ...

  9. Android(java)学习笔记184:生成 4种 不同权限的文件

    1.首先我们编写一个生成 4种 不同权限的文件的程序案例: (1)首先是activity_main.xml文件: <RelativeLayout xmlns:android="http ...

  10. linux下安装redis并自启动

    最近需要使用redis作为tomcat集群的session存储介质,因此记录redis的安装步骤.redis是一款高性能的nosql,支持异步将缓存写入到磁盘中,避免宕机的意外情况导致的缓存信息丢失. ...