Currently, Node.js steps can only be run inside a Docker container. TeamCity uses
node:lts by default, or, if there is an
.nvmrc file inside your project, it will search for the image specification there.
If your repository contains a
package.json file, TeamCity will automatically detect used frameworks and propose adding respective build steps.
If TeamCity detects an
.nvmrc file, it will automatically use the node version specified in it.
Running Node.js Commands
In the Shell script field, enter all Node.js commands to be executed in this step.
Accessing Private Registries
To access a private npm registry during a build (for example, to download a package), you need to:
In Project Settings | Connections, configure an NPM Registry connection: specify the registry URL, automation access token, and a scope.
The scope defines which registries will be accessed by the npm commands. It is a good practice to keep this specification in one place, that is in the connection settings: either in the TeamCity connection instance or directly in the
.npmrcfile. Alternatively, if you don't specify a scope in the connection settings, you can still access a specific registry within a Node.js step by appending
--registry registry_urlto the
In Build Configuration Settings | Build Features, add an NPM Registry Connection build feature and select the new connection, so it can be used in this configuration.
As a result, a TeamCity agent will authenticate in this registry during the build.
Alternatively to this procedure, you can let TeamCity parse a token from the
.npmrc file inside your JS project. To achieve this, declare a token variable in this file as specified here and then create an environment variable
NPM_TOKEN in TeamCity with the value of the access token and the "Password" type.