In this article you will learn how to deploy a local CNPM private repository with Docker, upload the NPM package to the private repository and download it for use. Suitable for the deployment of their own private NPM warehouse needs of the students, I personally practice, if necessary, can leave a message to discuss

Start the local Docker

MAC system directly open docker terminal to wait for the running state.

Download open source CNPM repository

git clone https://github.com/cnpm/cnpmjs.org.git
Copy the code

Go to the cnpmjs.org directory

cd cnpmjs.org
Copy the code

Start the container with docker-comemage. yaml

docker-compose up
Copy the code

Access to the test

127.0.0.1:7002 (127.0.0.1:7001 is the registery registered address)

Access and use the warehouse after successful deployment

CNPM config get registry // Check whether the registered address is http://127.0.0.1:7001/Copy the code

Example Change the REGISTERED ADDRESS of the CNPM

cnpm config setRegistry http://127.0.0.1:7001Copy the code

Local CNPM registration

CNPM login // Enter Username: winyh Password: Email: (this IS public) 1******[email protected] Logged as promptedinAs winyh on http://127.0.0.1:7001/.Copy the code

Logged in as winyh on http://127.0.0.1:7001/. Prove successful registration with the local private repository.

Publish packages to private repositories

cnpm publish
Copy the code

Terminal log:

NPM notice 📦 @cnpm/[email protected] NPM notice === Tarball Contents === NPM notice 176B dist/demo.html NPM Notice 200B lib/demo. HTML NPM notice 200B lib/demo. HTML NPM notice 200B lib/demo. HTML NPM notice 200B lib/demo. HTML NPM notice 200B lib/demo babel.config.js npm notice 139B packages/button/index.js npm notice 124B packages/col/index.js npm notice 699B packages/index.js npm notice 129B packages/list/index.js npm notice 174B packages/row/index.js npm notice 134B Packages /table/index.js NPM notice 418B SRC /main.js NPM notice 112.3KB lib/winyh-vue.com.js NPM notice 112.7KB Lib /winyh-vue.umd.js NPM notice 36.4kB Lib /winyh-vue.umd.min.js NPM notice 87.9kB Dist/winyh.mon.js NPM notice 88.3kB Dist /winyh.umd.js NPM notice 27.1kB Dist/Winyh.umd.min. js NPM notice 146B vue.config.js NPM notice 1.4kB package.json NPM notice 143.1kB lib/winyh-vue.mon.js. map NPM notice 143.6kB lib/winyh-vue.umd.js.map NPM notice 166.7kB Lib /winyh-vue. Umd.min.js. map NPM notice 108.1kB dist/winyh.mon.js. map NPM notice 108.7kB dist/winyh.umd.js.map NPM Notice 128.4 kB dist/winyh. Umd. Min. Js. Map NPM notice 587 b README. Md NPM notice 6.8 kB SRC/assets/logo PNG NPM notice 686 b SRC/App. Vue NPM notice 2.0 kB SRC/components/HelloWorld vue NPM notice 3.1 kB packages/button/SRC/main vue NPM notice 4.6 kB packages/col/SRC/main vue NPM notice 186 b packages/list/SRC/main vue NPM notice 2.8 kB packages/row/SRC/main vue NPM notice 3.2 kB packages/table/SRC/main vue NPM notice = = = Tarball Details = = = NPM notice name: @cnPM/winyH-vue NPM Notice Version: 0.0.1 NPM notice Package Size: 287.3 kB NPM notice Unpacked size: 1.3 MB NPM notice shasum: 0975 fe7f3015fbdaf52c2d92aa45c2e7b6873f08 NPM notice integrity: sha512 - I2FufzKRdCY5U [...]. g3o4rIEE6pG8Q== npm notice total files: 35Copy the code

Now that publishing to private repository is successful, view the package information

The local installation test succeeded

cnpm i @winyh-vue
Copy the code

The installation log

Recently updated (since 2019-11-28): 3 packages (detail see file /Users/winyh/Desktop/PLG/pkg/node_modules/.recently_updates.txt) Today: → <strong>@cnpm/winyh-vue@*(0.0.1)</strong> (12:30:06) All packages installed from NPM Registry, used 3S (network 2s), speed 54.51kB/s, JSON 46(131.27kB), tarball 0BCopy the code

At this point, the WinyH-Vue package has been successfully published and downloaded for use