Install Private npm Packages¶
You can use private npm packages within your Capawesome Cloud native builds by configuring a custom npm registry. This guide shows you how to set up authentication to access private packages from any npm registry provider.
Add Environment Secret¶
To access private npm packages, you need to configure an authentication token:
- Obtain your authentication token from your npm registry provider
- Add it to your Capawesome Cloud app as an environment secret with an appropriate name (e.g.,
NPM_REGISTRY_TOKEN) as described in Environment secrets
Keep your tokens secure
Never commit authentication tokens directly to your repository. Always use environment secrets to store sensitive information like authentication tokens.
Configure npm Registry¶
Create a new file named .npmrc in the root of your project with the following configuration:
@your-scope:registry=https://your-registry.example.com
//your-registry.example.com/:_authToken=${YOUR_NPM_REGISTRY_TOKEN}
Replace the following placeholders:
@your-scope: Your package scope (e.g.,@mycompany)https://your-registry.example.com: Your npm registry URL${YOUR_NPM_REGISTRY_TOKEN}: The name of your environment secret containing the authentication token
This configuration tells npm to use your custom registry for packages under your scope and authenticate using the environment secret.
Manage Multiple Environments¶
If your local development environment stops working with the new .npmrc file, you can create a separate configuration file specifically for Capawesome Cloud:
- Create a new file named
.npmrc.capawesomein the root of your project with the registry configuration - Navigate to your Capawesome Cloud app > Settings > Environment variables
- Add a new environment variable named
NPM_CONFIG_USERCONFIG - Set its value to
/tmp/capawesome/repo/.npmrc.capawesome
Custom file location
If your .npmrc.capawesome file is not in your project's root directory, adjust the path in the NPM_CONFIG_USERCONFIG environment variable accordingly.
This approach allows you to maintain separate npm configurations for local development and Capawesome Cloud builds.