This article corresponds to the CNPM version of v2.12.2, floating up and down some compatible version of the problem is not particularly large .
To deploy CNPM, you need to do some of the following preparations.
Deployment of the host, such as servers, cloud hosts, their own computers, etc.;
Database, support MySQL, PostgreSQL, MariaDB, if you use SQLite do not need to prepare;
Git Client (recommended).
under Brother Lian Education ( www.lampbrother.net ) to guide you start deployment of clone CNPM
First select a directory locally, for example I will choose it in/usr/app, and then envision CNPM directory for/USR/APP/CNPM, then need in terminal $ cd/usr/app.
Then execute the Git instruction to clone the CNPM to the appropriate directory.
$ git clone https://github.com/cnpm/cnpmjs.org.git
Windows Users
Windows users can also run Git with similar Cygwin, MinGW, Powershell, or even direct Command.
Of course, you can also download some GUI tools directly to clone, such as Sourcetree.
Non-Git users
Go to CNPM's release page and select the appropriate version to download, for example, v2.12.2 version will be selected here.
After the download is complete, unzip the folder to the appropriate directory.
Installation dependencies
Install dependency is actually a NPM install, but cnpm the instructions have been written into the Makefile inside, so the direct execution of the following command is good.
$ make Install
Of course, if you are a Windows user or do not make, then use NPM install.
$ npm Install--build-from-source--registry=https://registry.npm.taobao.org--disturl=https://npm.taobao.org/mirrors/node
Modifying a configuration file
Create a new copy of the Config/config.js file and write the following skeleton:
Javascript
' Use strict ';
Module.exports = {
};
Enter the key-value pairs you need in this area.
Some common configuration items will be listed here, and some of the remaining configuration items should refer to the Config/index.js file yourself.
Configuration field Reference
Enablecluster: Whether to enable Cluster-worker mode to start the service, default false, the production process is recommended to true;
Registryport:api dedicated Registry service port, default 7001;
Webport:web service port, default 7002;
Bindinghost: Listens on the bound Host, the default is 127.0.0.1, if the outside of a layer of local nginx reverse proxy or Apache reverse proxy, the recommendation does not change;
Salt used for sessionsecret:session;
LogDir: Log directory;
Uploaddir: temporary upload file directory;
Viewcache: Whether the view template cache is turned on, default to false;
Enablecompress: If gzip compression is turned on, the default is false;
Admins: Administrators, this is a JSON Object, corresponding to each key name for each administrator's user name, the key value for its mailbox, the default is {fengmk2: ' [email protected] ', admin: ' [email protected] ', Dead_ Horse: ' [email protected] '};
Logourl:logo address, but for me this has CNPM front-end changed beyond recognition of the person has neglected this configuration;
Adbanner: The address of the advertisement Banner;
Customreadmefile: Actually we see the cnpmjs.org home in the middle of a lot of lengthy introduction is a Markdown file converted into, you can set the item from the line to replace this file;
Customfooter: custom footer template;
Npmclientname: The default is CNPM, if you have your own development or fork of the NPM client, please change to your CLI command, this should be in some of the pages of the instructions to replace the words you wrote;
Backupfileprefix: Backup directory;
Database: Databases related configuration, for an object, default if not configured will be a ~/.cnpmjs.org/data.sqlite sqlite;
DB: The database name of the data;
Username: database user name;
Password: database password;
Dialect: Database adapter, optional "MySQL", "SQLite", "Postgres", "mariadb", the default is "SQLite";
Hsot: Database address;
Port: Database ports;
Pool: Database connection pool-related configuration, as an object;
MaxConnections: Maximum number of connections, default is 10;
Minconnections: Minimum number of connections, default is 0;
MaxIdleTime: Maximum idle time for single link, default is 30000 milliseconds;
Storege: Only valid for SQLite configuration, database address, default is ~/.cnpmjs/data.sqlite;
NFS: Package file System processing object, for a node. JS object, the default is FS-CNPM this package, and configured in the ~/.cnpmjs/nfs directory, that is, the default all synchronized packages will be placed in this directory , developers can use other file system plug-ins (such as uploading to the cloud and so on), or to develop a logical layer by their own interface, these are something;
Registryhost: Not yet, I guess for the Web page display, the default is r.cnpmjs.org;
Enableprivate: Whether to turn on private mode, default to FALSE;
If it is private mode, only the administrator can publish the package, others can only synchronize the package from the source station;
If non-private mode, all logged-in users can publish the package;
Scopes: Non-admin release package can only be used to scopes the namespace listed in the prefix to publish, if not set can not be published, that is, this is a required, the default is [' @cnpm ', ' @cnpmtest ', ' @cnpm-test '], According to Suchi greatly explained is to facilitate management and let the company's employees consciously on-demand release; For more information on NPM scope, see Npm-scope;
Privatepackages: As noted in the notes to this configuration item, for historical reasons, some of the already existing private packages (which may have been installed previously in Git) are not named in the namespace, and this package could not have been uploaded to CNPM, This array of configuration items is used to add these exceptions to the whitelist, the default is an empty array;
Sourcenpmregistry: Update the registry address of the source NPM, default to https://registry.npm.taobao.org;
SOURCENPMREGISTRYISCNPM: If the source registry is CNPM, the default is true, set it to False if the source you are using is the official NPM source.
Syncbyinstall: If the package is found to be not present when it is installed, try to synchronize from the update source, which defaults to true;
Syncmodel: Update mode (but I think it is a typo), there are several modes can be selected, the default is "none";
"None": Never sync, only manage the packages uploaded by private users, other source packages will be obtained directly from the source station;
"Exist": Timed synchronization already exists in the database package;
"All": Timing synchronization of all source station packages;
Syncinterval: Synchronization interval, the default is "10m" that is 10 minutes;
Syncdevdependencies: Whether to synchronize the Devdependencies packets inside each package, the default is false;
Badgesubject: The badge display name of the package, the default is CNPM;
UserService: User authentication interface, the default is null, that is, no user-related functions that can not have users to upload the package, the part needs to implement the interface function and configuration, such as the company's Gitlab relative, which is something;
Alwaysauth: Whether user authentication is always required, even if the command is CNPM install;
Httpproxy: Proxy address settings, used when you are in the wall of the source station outside the wall situation.
Introduction to the basic deployment method of CNPM