Configuring and using npm
To use npm
with CodeCatalyst, you must connect npm
to your
package repository and provide a personal access token (PAT) for authentication. You can view
instructions for connecting npm
to your package repository in the CodeCatalyst console.
Contents
Configuring npm with CodeCatalyst
The following instructions explain how to authenticate and connect npm
to your CodeCatalyst package repository. For more information about npm, see the
official npm documentation
To connect npm
to your CodeCatalyst package repository
-
Open the CodeCatalyst console at https://codecatalyst.aws/
. -
Navigate to your project.
-
In the navigation pane, choose Packages.
-
Choose your package repository from the list.
-
Choose Connect to repository.
-
In Configuration details, in Package manager client, choose npm client.
Choose your operating system to view the corresponding configuration steps.
-
A personal access token (PAT) is required to authenticate npm with CodeCatalyst. If you already have a token, you can use it. If not, you can create one using the following steps.
(Optional): Update the PAT name and Expiration date.
-
Choose Create token.
-
Copy and store your PAT in a safe location.
Warning
You will not be able to see or copy your PAT again after you close the dialog box. Credentials should be short lived to minimize the length of time an attacker can use the credentials after misappropriating them.
-
Run the following commands from your project's root directory to configure npm with your package repository. The commands will do the following:
Create a project-level
.npmrc
file if your project does not have one.Add the package repository endpoint information to your project-level
.npmrc
file.Add your credentials (PAT) to your user-level
.npmrc
file.
Replace the following values.
Note
If you are copying from the console instructions, the values in the following commands are updated for you and do not need to be changed.
Replace
username
with your CodeCatalyst user name.Replace
PAT
with your CodeCatalyst PAT.Replace
space_name
with your CodeCatalyst space name.Replace
proj_name
with your CodeCatalyst project name.Replace
repo_name
with your CodeCatalyst package repository name.
npm set registry=https://packages.
region
.codecatalyst.aws/npm/space-name
/proj-name
/repo-name
/ --location project npm set //packages.region
.codecatalyst.aws/npm/space-name
/proj-name
/repo-name
/:_authToken=username
:PAT
For npm 6 or lower: To make npm always pass the auth token to CodeCatalyst, even for
GET
requests, set the always-auth configuration variable withnpm config set
as follows.npm set //packages.
region
.codecatalyst.aws/npm/space-name
/proj-name
/repo-name
/:always-auth=true --location project
Installing npm packages from a CodeCatalyst package repository
After you connect npm to your repository by following the steps in Configuring npm with CodeCatalyst, you can run npm
commands on your repository.
You can install an npm package that is in your CodeCatalyst package repository or one of
its upstream repositories with the npm install
command.
npm install
lodash
Installing npm packages from npmjs through CodeCatalyst
You can install npm packages from npmjs.com
To install packages from npmjs
-
If you haven't already done so, configure
npm
with your CodeCatalyst package repository by following the steps in Configuring npm with CodeCatalyst. -
Check that your repository has added the gateway repository, npm-public-registry-gateway, as an upstream connection. You can check which upstream sources are added or add npm-public-registry-gateway as an upstream source by following the instructions in Adding an upstream repository and choosing the npm-public-registry-gateway repository.
-
Install packages with the
npm install
command.npm install
package_name
For more information about requesting packages from upstream repositories, see Requesting a package version with upstream repositories.
Publishing npm packages to your CodeCatalyst package repository
After you have completed Configuring npm with CodeCatalyst, you can run npm
commands.
You can publish an npm package to a CodeCatalyst package repository with the npm publish
command.
npm publish
For information about how to create npm packages, see Creating Node.js
Modules
npm command support
The following sections summarize the npm
commands that are supported by CodeCatalyst
package repositories, in addition to listing specific commands that are not
supported.
Topics
Supported commands that interact with a package repository
This section lists npm
commands where the npm
client makes one
or more requests to the registry to which it is configured (for example, npm
config set registry
). These commands have been verified to function
correctly when invoked against a CodeCatalyst package repository.
Command | Description |
---|---|
Guesses the location of a package’s bug tracker URL, and then it attempts to open it. |
|
Installs a project with a clean slate. |
|
Deprecates a version of a package. |
|
Modifies package distribution tags. |
|
Guesses the location of a package’s documentation URL, and then it
attempts to open it by using the |
|
Runs a set of checks to validate that your npm installation can manage your JavaScript packages. |
|
Installs a package. |
|
Installs a project with a clean slate and runs tests. Alias: |
|
Installs package and runs tests. Runs an |
|
Checks the configured registry to determine if any installed packages are outdated. |
|
Pings the configured or given npm registry and verifies authentication. |
|
Publishes a package version to the registry. |
|
Guesses the location of a package’s repository URL, and then it attempts
to open it by using the |
|
Displays package metadata. Can also be used to print metadata properties. |
Supported client-side commands
These commands don't require any direct interaction with a package repository, so CodeCatalyst does not require anything to support them.
Command | Description |
---|---|
Displays the npm |
|
Builds a package. |
|
Manipulates the packages cache. |
|
Enables tab completion in all npm commands. |
|
Updates the contents of the user and global |
|
Searches the local package tree and attempts to simplify the structure by moving dependencies further up the tree where they can be more effectively shared by multiple dependent packages. |
|
Edits an installed package. Selects a dependency in the current working directory and opens the package directory in the default editor. |
|
Browses an installed package. Spawns a subshell in the directory of the specified installed package. If a command is specified, then it is run in the subshell, which then immediately shuts down. |
|
Gets help on npm. |
|
Searches npm help documentation. |
|
Creates a |
|
Symlinks a package directory. |
|
Lists installed packages. |
|
Creates a tarball from a package. |
|
Displays a prefix. This is the closest parent directory to contain a
|
|
Removes packages that are not listed on the parent package's dependencies list. |
|
Runs the |
|
Runs a package's stop, restart, and start scripts and associated pre-scripts and post-scripts. |
|
Prints the effective |
|
Runs arbitrary package scripts. |
|
Locks down dependency versions for publication. |
|
Uninstalls a package. |
Unsupported commands
These npm
commands are not supported by CodeCatalyst package repositories.
Command | Description | Notes |
---|---|---|
Sets the access level on published packages. |
CodeCatalyst uses a permission model that is different from the public npmjs repository. |
|
Adds a registry user account |
CodeCatalyst uses a user model that is different from the public npmjs repository. |
|
Runs a security audit. |
CodeCatalyst does not currently vend security vulnerability data. |
|
Manages npm hooks, including adding, removing, listing, and updating. |
CodeCatalyst does not currently support any change notification mechanism. |
|
Authenticates a user. This is an alias for |
CodeCatalyst uses an authentication model that is different from the public npmjs repository. For information, see Configuring npm with CodeCatalyst. |
|
Signs out of the registry. |
CodeCatalyst uses an authentication model that is different from the public npmjs repository. There is no way to sign out from a CodeCatalyst repository, but authentication tokens expire after their configurable expiration time. The default token duration is 12 hours. |
|
Manages package owners. |
CodeCatalyst uses a permissions model that is different from the public npmjs repository. |
|
Changes settings on your registry profile. |
CodeCatalyst uses a user model that is different from the public npmjs repository. |
|
Searches the registry for packages matching the search terms. |
CodeCatalyst does not support the |
|
Marks your favorite packages. |
CodeCatalyst currently does not support any favorites mechanism. |
|
Views packages marked as favorites. |
CodeCatalyst currently does not support any favorites mechanism. |
|
Manages teams and team memberships. |
CodeCatalyst uses a user and group membership model that is different from the public npmjs repository. |
|
Manages your authentication tokens. |
CodeCatalyst uses a different model for getting authentication tokens. For information, see Configuring npm with CodeCatalyst. |
|
Removes a package from the registry. |
CodeCatalyst does not support removing a package version from a repository by using the npm client. You can delete a package in the console. |
|
Displays the npm user name. |
CodeCatalyst uses a user model that is different from the public npmjs repository. |