npm Configuration

This plugin uses npm (a tool provided by Node.js) to run Antora. This page covers various ways to tune the npm configuration when using this plugin.

Due to bug in the frontend-maven-plugin, the npm calls made by the Antora Maven plugin do not inherit the proxy config from Maven. Therefore, it’s necessary to configure the proxy (again) using the npm configuration (https-proxy, proxy, and noproxy).

npm_config environment variables

npm can be configured using environment variables. These environment variables start with the prefix npm_config_. An example is npm_config_registry, which sets the URL of the registry from which npm packages are retrieved.

When the plugin calls npm, it inherits environment variables from the shell that’s used to invoke Maven. Therefore, one way to set an npm_config environment variable is to set it when Maven is run.

$ npm_config_registry=https://registry.yarnpkg.org antora:antora

The antora:antora goal provides the environmentVariables parameter for defining additional environment variables when running Antora. Therefore, you can set an npm_config environment variable using that parameter instead.

pom.xml
<configuration>
  <npm_config_registry>https://registry.yarnpkg.org</npm_config_registry>
</configuration>

If the environment variable is set both ways, the one from the plugin configuration takes precedence.

.npmrc

Another way to configure npm is to use a configuration file. The name of this configuration file is .npmrc. This file can be placed in the current project and/or in your user directory.

Each line in the file is a single configuration option with the syntax name=value. Unlike the environment variables, the name of the option is not prefixed with npm_config_. An example is registry, which sets the URL of the registry from which npm packages are retrieved.

.npmrc
registry=https://registry.yarnpkg.com

Refer to npm Config Settings for a complete inventory of the configuration settings. Keep in mind that not all configuration settings are applicable to how this plugin uses npm.