verdaccio搭建npm私有库

Server

  • server:all developers can have access to it, the server environment is windows.

We need to use the npm command to install verdaccio, so we have to have a node environment.

step1: install the node environment

《verdaccio搭建npm私有库》

  • install node
  • Verify that the installation was successful

Open cmd and input ‘node -v’

《verdaccio搭建npm私有库》

step2:Installation start verdaccio

  • Install verdaccio

Open cmd and input ‘npm install -g verdaccio’

《verdaccio搭建npm私有库》

  • Start verdaccio

input ‘verdaccio’

《verdaccio搭建npm私有库》

After the startup is successful, open http://localhost:4873/ and see the interface is successful.

《verdaccio搭建npm私有库》

  • Configuration file

Find the configuration file of verdaccio, You can modify the configuration by referring to https://verdaccio.org/docs/en…

《verdaccio搭建npm私有库》

verdaccio runs by default in the port 4873,we can change the listen address and port.

《verdaccio搭建npm私有库》

After change the configurations,then restart the verdaccio, open http://10.137.118.26:3001/#/ and can see the interface like below

《verdaccio搭建npm私有库》

The private repository has been set up.

Client configuration

We need to use our client to configure our registry to use our private repository.The client is the developer’s development computer.You need to install the node environment.

  • npm release package

you need to register or login your account. If we don’t have an account yet, we can create it by entering the command npm adduser –registry http://10.137.118.26:3001 and then entering the username in turn. If you already have an account, you can log in by entering the command npm login –registry http://10.137.118.26:3001 and then entering the username and password. Then enter the code directory we need to upload, execute the command to publish.

Just got a project name called ‘example’, there is nothing in it, npm init creates a new package.json.The package.json code is as follows:

《verdaccio搭建npm私有库》

register account like below:
when we register a account,it will auto login.

《verdaccio搭建npm私有库》

Then we can use the npm publish command to publish the package.

《verdaccio搭建npm私有库》

And,we can see the package published success.

《verdaccio搭建npm私有库》

  • npm download package

Just open a project called ‘test’, Use the command npm install ‘@sfc/example’ to download the npm package we just posted to private.

《verdaccio搭建npm私有库》
《verdaccio搭建npm私有库》

《verdaccio搭建npm私有库》

After the download is complete, we can see the example file in the node_modules folder of the project.

《verdaccio搭建npm私有库》

    原文作者:jianwenjuan
    原文地址: https://segmentfault.com/a/1190000019196458
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞