Node.js
The Node.js build runner allows running Node.js tools like npm
, yarn
, and node
.
Refer to Configuring Build Steps for a description of common build steps' settings.
Currently, Node.js steps can only be run inside a Docker/LXC container. Refer to Container Wrapper for general information about available Docker/Podman settings.
You can define which version of Node.js to use for the current build step. TeamCity uses a node:lts
image by default, or, if there is a .nvmrc
file inside your project, TeamCity automatically detects the image specification from there while creating a build step.
If your repository contains a package.json
file, TeamCity will automatically detect used frameworks and propose adding respective build steps.
note
If TeamCity detects a dependency on a test framework, it will propose choosing between two steps: run tests via this framework or with a general
test
command. To display structured test reports in TeamCity, select the step with the framework.
Currently supported frameworks are ESlint, Jest, and Mocha.
If TeamCity detects an .nvmrc
file, it will automatically use the node version specified in it.
In the Shell script field, enter all Node.js commands to be executed in this step.
To access a private npm registry during a build (for example, to download a package), you need to:
Configure an NPM Registry connection as described here.
Navigate to Administration | <Your Configuration> to access build configuration settings.
Open the Build Features settings tab.
Add an NPM Registry Connection build feature and select the connection created in step 1.
As a result, a TeamCity agent will authenticate in this registry during the build.
note
Note that TeamCity will only be able to access registries where automation tokens are allowed. If your connection test fails in TeamCity, revise the registry settings.
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.
warning
If a token is configured in your NPM registry connection, TeamCity will use it for connecting to this registry. However, there is known issue when TeamCity might use the token specified in the
.npmrc
file instead of that in the connection settings. See the workarounds to this issue in our tracker.
Thanks for your feedback!