In npm, a scope is a way to group related packages together. Scoped packages are prefixed with an @ symbol followed by the scope name and a slash. For example, @realtair/cdk is a package under the @realtair scope.

Scopes in npm

  1. Purpose:

    • Scopes help organize packages, especially in large organizations or projects with many related packages.
    • They can also be used to manage access control, as scoped packages can be published to private registries.
  2. Structure:

    • A scoped package name looks like @scope/package-name.
    • Example: @realtair/cdk.
  3. Registry Configuration:

    • You can configure different registries for different scopes in the .npmrc file.
    • This is useful if you want to pull packages from different sources, such as a private registry for your organization’s packages and the public npm registry for open-source packages.

Example .npmrc Configuration

To configure a custom registry for a specific scope, you can add entries to your .npmrc file:

@realtair:registry=https://your.custom.registry.domain/

This tells npm to fetch packages under the @realtair scope from https://your.custom.registry.domain/.

Example Usage

Given the package.json content you provided, if you want to pull @realtair/cdk from a custom registry, you would:

  1. Create or update the .npmrc file in your project directory.
  2. Add the following line:
@realtair:registry=https://your.custom.registry.domain/

This configuration ensures that when you run npm install, the @realtair/cdk package will be fetched from the specified custom registry.