Learn how to distribute your private NodeJS packages.
The package scope and name must match the product identifier in order to work.
So make sure you adjust your package.json
and set the package name to @your-product-identifier/your-product-identifier
:
1{2 "name": "@your-product-identifier/your-product-identifier", 3 "version": "1.0.0",4 "description": "Cool product description",5 //...6}
Your NPM customers can use the npx
helper provided by Unlock to get started with just a single command:
1npx unlock-pkg your-product-identifier [license-key]
To manually add the package or when using yarn the following commands must be executed.
First, add the following repository to the npm
or yarn
config with the following command.
1# NPM2npm config set @your-product-identifier:registry 'https://your-product-identifier.nodejs.pub'3 4# Yarn5yarn config set @your-product-identifier:registry 'https://your-product-identifier.nodejs.pub'
Next, they will need to set their license key (and fingerprint if applicable).
1# NPM2npm config set '//your-product-identifier.nodejs.pub/:_authToken' '[license-key]'3 4# Yarn5yarn config set '//your-product-identifier.nodejs.pub/:_authToken' '[license-key]'
If your license policy requires a fingerprint the user will need to append his/her fingerprint to their license key. For example, let's say we have the following licensee and license activation:
aaaff29c-94e7-4d59-ab95-86b4248d9443
unlock.sh
This will require your licensee to set the following config:
1# NPM2npm config set '//your-product-identifier.nodejs.pub/:_authToken' 'aaaff29c-94e7-4d59-ab95-86b4248d9443:unlock.sh'3 4# Yarn5yarn config set '//your-product-identifier.nodejs.pub/:_authToken' 'aaaff29c-94e7-4d59-ab95-86b4248d9443:unlock.sh'
Next, run the install command:
1# NPM2npm install @your-product-identifier/your-product-identifier3 4# Yarn5npm add @your-product-identifier/your-product-identifier