Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CNPM 搭建私有 NPM 服务 #3

Open
luqin opened this issue Aug 13, 2015 · 1 comment
Open

CNPM 搭建私有 NPM 服务 #3

luqin opened this issue Aug 13, 2015 · 1 comment

Comments

@luqin
Copy link
Owner

luqin commented Aug 13, 2015

参考:

环境依赖

  • Linux
  • Node >= 0.12.2, use --harmony
  • NPM >= 2.7.6
  • PostgreSQL >= 9.4

下载代码

当前最新版本:2.0.0-rc.15

# clone from github
$ git clone git://github.com/cnpm/cnpmjs.org.git $HOME/cnpmjs.org
$ cd $HOME/cnpmjs.org

修改配置

$ vim config/config.js
module.exports = {
  bindingHost: '127.0.0.1', // only binding on 127.0.0.1 for local access

  // input your custom config here
  admin: {
    'admin': '***'
  },

  /**
   * database config
   */

  database: {
    db: 'cnpmjs',
    username: 'postgres',
    password: '',

    // the sql dialect of the database
    // - currently supported: 'mysql', 'sqlite', 'postgres', 'mariadb'
    dialect: 'postgres',

    // custom host; default: 127.0.0.1
    host: '127.0.0.1',

    // custom port; default: 3306
    port: ***,

    // use pooling in order to reduce db connection overload and to increase speed
    // currently only for mysql and postgresql (since v1.5.0)
    pool: {
      maxConnections: 10,
      minConnections: 0,
      maxIdleTime: 30000
    },

    logging: !!process.env.SQL_DEBUG,
  },

  // registry scopes, if don't set, means do not support scopes
  scopes: ['@mycnpm']
};

安装依赖

# install dependencies
$ make install

创建数据库

# 创建数据库:cnpmjs

初始化数据库

$ node --harmony models/init_script.js 

启动服务

$ npm run start

For Windows: node --harmony dispatch.js

后台进程启动

nohup node --harmony /root/cnpmjs.org/dispatch.js > /root/cnpmjs.org/startlog.log 2>&1 &

关闭后台进程

ps -ef | grep node
kill -9 pid

检查

#open registry and web
# registry
http://myip:7001
# web
http://myip:7002

注册自启动

cd /root/cnpmjs.org/
vi start.sh

输入脚本保存:

nohup node --harmony /root/cnpmjs.org/dispatch.js > /root/cnpmjs.org/startlog.log 2>&1 &

增加软链接:

ln -s start.sh /etc/init.d/cnpm

CNPM 使用文档

CNPM 使用文档

@luqin luqin changed the title CNPM 搭建私有 NPM 服务 - Linux CNPM 搭建私有 NPM 服务 Jan 8, 2016
@luqin
Copy link
Owner Author

luqin commented Apr 5, 2016

cnpmjs.org 升级

2.0.0-rc.15 => 2.9.2

安装 nvm

https://github.com/creationix/nvm

升级 Node.js => v5.10.0

……

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant