Private NPM deployment

[TOC]

Background: To force grid’s promotion. Simple wordy once, can be ignored.

  1. Currently, we have multiple projects on our team that are being developed simultaneously, and the components in each project are very reusable. In order to reduce the time needed to modify a large amount of code in each project, we only need to modify it once in the private CNPM repository, and then update the corresponding package in each project in turn, and the problem is solved.
  2. It is convenient to see how many components there are in the team and how they are used, so that each member has the power to extract components and promote the rapid growth of the team.
  3. There is no shortage of deadlines in the development process, but this is the time to encounter complex business. Before this is the first to do before the project code reading side, in the key code copy over, debugging. It just so happens that you didn’t write the code yourself. It may take some time to read the following code logic. Oh, my God! Is not small along while past, but also can happily eat chicken.

I. Deployment mode

  • Private NPM deployment mode
    1. cnpm
    2. sinopia
    3. verdaccio
  • Reason why CNPM is selected
    1. CNPM server through the KOA framework for development, convenient subsequent view of the source code.
    2. Support MSYQL, data migration is convenient,
    3. Domestic CNPM team development, easy to find problems.

Two, preliminary preparation

  1. Linux environment (MAC users ignore)
    • Refer to the address
    • VMware
    • Centos or ubuntu
  2. Mysql installation
  3. Navicate connection mysql
  4. NRM manages NPM sources

Three, CNPM installation

  1. Download CNPMJS
     #clone from github
     $ git clone git://github.com/cnpm/cnpmjs.org.git
     $ cd cnpmjs.org
     #create mysql tables, start mysql in CNPM
     $mysql -u root -p
     mysql> create database cnpmjs
     mysql> use cnpmjs;
     mysql> source docs/db.sql
    Copy the code
  2. Modifying a Configuration File
    • To prevent misoperations, do not modify config/index.js. We’ll create index.js under config
      $ vim config/config.js
    Copy the code
      module.exports = {
        debug: false,
        database: {
        db: 'cnpmjs'// Database name, default is cnPMjs_test host:'127.0.0.1', // server address port: 3306, // port:'root'// username, password:'123456'// For cento or Ubuntu, if you use the root user name to connect to the database, set the password to empty. Dialect:'mysql'// use mysql, default sqLite, postgres, Mariadb, temporarily not oracle}, admins: {admin:'[email protected]'// Admin permissions}, scopes: ['@vt'], // Private packages must be attached to the scope registryHost:'127.0.0.1:7001'// Replace server IP bindingHost:'0.0.0.0'
      };
    Copy the code

3. Start the service

  • Windows users
    #cnpmjs.org directory to start
    node diapatch.js  
    Copy the code
  • Through the window
    npm start
    npm restart
    npm stop
    Copy the code

    asdf

4. Release of CNPM package

NRM add local http://127.0.0.1:7001/ NRM use local NRM ls NPM login NPM publish # NPM info # Create a project to download NPM install @vt/zhangle ```Copy the code

Five, climb pit secret book

  • It is recommended to use git clone git://github.com/cnpm/cnpmjs.org.git use global installation is not recommended by NPM install cnpmjs.org for installation, need to find the global installation location (cnpmjs.org / root/.nvm/versions/node/v10.15.3/lib/node_modules/cnpmjs.org), which modify the config/config. Js via cnpmjs.org start
  • CNPM 7002 can be accessed normally, but port 7001 fails to be accessed. Most likely, there is no connection to the database.
  • Most of the startup problems are caused by config/index.js configuration problems.
  • If you want to access ali cloud, you need to do the following security policies: Ports 7001 and 7002 are open to the public.
  • Communicate cannot connect to the mysql database
``` mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION; Query OK, 0 rows affected (0.00 SEC) mysql>FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 SEC) ' 'Copy the code
  • If 7001 cannot be accessed using SQlite3, node./models/init_script.js sqlite is required for initialization

subsequent

  • There is no NPM list, it can only be supplemented through search, and the interface needs to be optimized
  • There is currently no specification documentation for component development.
  • The server Docker deployment is not complete

The resources

  1. github cnpm
  2. docker cnpm
  3. sinopia