Javascript Package - Registry

> (World Wide) Web - (W3|WWW) > Javascript (Js|ECMAScript) > Javascript Package

1 - About

Code Shipping - Registry in Javascript

A registry is:


2.1 - Properties

2.1.1 - Scope

If a scope is associated with a registry:

  • any install for a package with that scope will request packages from the scoped registry
  • any publish for a package name that contains the scope will be published to the scoped registry.
npm config set @myco:registry

3 - List

See also: cdn to get a link to the library

4 - CDN


5 - Management

5.1 - Set

5.1.1 - Set globally

npm set registry http://localhost:4873

5.1.2 - Set for a project

Javascript Package - Package.json has a publishConfig property with:


    "publishConfig": {
        "registry": "https://your-host:8081/repository/npm-private/"

5.1.3 - Set at the command line

  • For one package
// locally for the project
npm install lodash --registry http://localhost:4873
// globally
npm --registry https://your-host:8081/repository/npm-group/ install -g packageName

5.2 - Command

5.2.1 - Publish

To publish

  • Filter the file to publish by adding the files to ignore in .npmignore or .gitignore
  • Be sure to not have the private property
   "private": true, // Prevent every publication
  • Generate a hash from the credential
echo -n 'admin:admin123' | openssl base64
YWRtaW46YWRtaW4xMjM=  # verify that you get the same value (this command can run also on windows and will not give the same result)
  • Add a .npmrc file to the proejct root that will get the credential (A .npmrc'' is a configuration file that should not be under version control. ie add it in your .gitignore file)
email=[email protected]
  • Test your package with an install command before publication
cd project
yarn install # to test 
# or
yarn install /path/to/project
npm publish
npm notice === Tarball Details ===
npm notice name:          @bytle/webco
npm notice version:       1.0.0
npm notice package size:  100.8 kB
npm notice unpacked size: 339.0 kB
npm notice shasum:        6faef3c35e3dab67320ab6f09d17752dba9a1fc3
npm notice integrity:     sha512-D/NtNsaN20yRK[...]ULMgIRHjUkyog==
npm notice total files:   41
npm notice

For instance, in Repository Manager - Nexus:


5.2.2 - Install

npm install