Javascript Package - Registry

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 http://reg.example.com

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:

Example:


{
    .....
    "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)


Powered by ComboStrap