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私有库_第1张图片

  • install node
  • Verify that the installation was successful

Open cmd and input 'node -v'

clipboard.png

step2:Installation start verdaccio

  • Install verdaccio

Open cmd and input 'npm install -g verdaccio'

clipboard.png

  • Start verdaccio

input 'verdaccio'

verdaccio搭建npm私有库_第2张图片

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

verdaccio搭建npm私有库_第3张图片

  • Configuration file

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

verdaccio搭建npm私有库_第4张图片

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

verdaccio搭建npm私有库_第5张图片

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

verdaccio搭建npm私有库_第6张图片

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私有库_第7张图片

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

verdaccio搭建npm私有库_第8张图片

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

verdaccio搭建npm私有库_第9张图片

And,we can see the package published success.

verdaccio搭建npm私有库_第10张图片

  • 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私有库_第11张图片

verdaccio搭建npm私有库_第12张图片

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

verdaccio搭建npm私有库_第13张图片

你可能感兴趣的:(javascript,node.js,windows-server)