Configuring Node.js

Vaadin uses the Node.js runtime in development mode to run the Webpack development server, as well as the Node.js package manager (npm) and package runner (npx) to fetch, install and run frontend packages.

Node.js can be installed in three different ways:

  • Automatically into user’s home directory (~/.vaadin/node). Only supported by Vaadin 14.2 and newer.

  • Globally with downloaded installer or package manager (such as Homebrew). Node.js can be downloaded from https://nodejs.org/en/download/. Installing Node.js automatically installs the command-line tools npm and npx as well.

  • Project-local installation (*project_dir*/node) using the frontend-maven-plugin[https://github.com/eirslett/frontend-maven-plugin].

If Node.js is found globally, Vaadin validates that it is a supported version; if it is too old, it installs a compatible version into ~/.vaadin. We recommend using the latest LTS version. A project-local installation will always take precedence over a global or ~/.vaadin installation.

Proxy Settings for Downloading Frontend Toolchain

If you are behind a proxy server you should config your proxy settings so Vaadin can use them to download the frontend toolchain. There are four places where Vaadin read proxy settings from. You can set your proxy data in either of the followings:

  1. system properties:

  2. {project directory}/.npmrc file

  3. {user home directory}/.npmrc file

  4. environment variables

The settings are read from the list above in order. For example, if you set your proxy in system properties, other sources will be ignored. The keys that you should use to define your proxy settings are as follows:

In System Properties and Environment Variables

In .npmrc files

Description

HTTP_PROXY

proxy

a proxy to use for outgoing http requests

HTTPS_PROXY

https-proxy

a proxy to use for outgoing https requests

NOPROXY

noproxy

a comma-separated string of domain extensions that a proxy should not be used for

.npmrc file structure is ini (like Java properties files). It includes pairs of key-values separated by =. Here is an example of the content of such a file with proxy settings:

  1. proxy=http://myusername:s3cr3tpassw0rd@proxyserver1:8085"
  2. https-proxy=http://myusername:s3cr3tpassw0rd@proxyserver1:8086"
  3. noproxy=192.168.1.1,vaadin.com,mycompany.com

To learn more about .npmrc file you can see official npmrc document.

Building an Application using Travis CI

If you are using Travis as a Continuous Integration server then there are two different options to install a proper Node.js version:

  1. Specify the version via Travis configuration in .travis.yml.

  2. Install Node.js automatically by Vaadin

Please refer to Specifying Node.js versions in Travis docs how to specify the Node version via .travis.yml file.

You may force Node.js installation to the ~/.vaadin folder via the require.home.node property. This property sets the Maven requireHomeNodeExec parameter value, so you may configure the Maven goal using <requireHomeNodeExec>true</requireHomeNodeExec>. To force node installation into home directory in development mode you should use vaadin.require.home.node system property or require.home.node web init parameter.