LabKey Server has a dependency on Node.js and the node package manager (npm).

Building LabKey

The build process will download the versions of npm and node that are specified by the properties npmVersion and nodeVersion, respectively, which are defined in the root-level gradle.properties file of the LabKey enlistment. This means you no longer need to, nor should you, install npm and node yourself.

To build LabKey, you must have the build-prod script defined. See below.

Node and npm Versions

If you are curious about the current versions in use, you can find those details in this file. Look for 'npmVersion' and 'nodeVersion':

You can also use direnv to ensure that the node and npm versions you are using match what the LabKey build is using.

package.json Scripts

To build LabKey, the package.json file (at the root of your module) should contain specific "scripts" targets, namely:

  • Required:
    • build-prod: Script used by npm to build in production mode.
  • Used for Local Development:
    • build: Script used by npm to build in dev mode.
    • start: Run locally to start the webpack dev server
    • test: Run locally to run jest tests.
    • clean: Convenience script to clean generated files. Does not delete downloaded node_modules.
  • Required for TeamCity (also requires TeamCity configuration to set up modules to run jest tests):
    • teamcity: Runs jest tests with a TeamCity plugin

Running npm on Command Line

If you run npm commands from the command line, it is strongly recommended that you put the downloaded versions of node and npm in your path. (Both are required to be in your path for the npm commands to run.) For these purposes, on non-Windows systems, the deployApp command creates symlinks for both node and npm in the directory .node at the root level of your enlistment:

trunk$ ls -la .node/
total 0
drwxr-xr-x 4 developer staff 128 Jun 14 14:11 .
drwxr-xr-x 38 developer staff 1216 Jun 18 10:36 ..
lrwxr-xr-x 1 developer staff 90 Jun 14 14:11 node -> /Users/developer/Development/labkey/trunk/build/modules/core/.node/node-v8.11.3-darwin-x64
lrwxr-xr-x 1 developer staff 77 Jun 14 13:58 npm -> /Users/developer/Development/labkey/trunk/build/modules/core/.node/npm-v5.6.0

You should add <LK_ENLISTMENT>/.node/node/bin and <LK_ENLISTMENT>/.node/npm/bin to your path environment variable. This is a one-time operation. The target of these links will be updated to reflect any version number changes. (Note that the directory won't exist until you run a deployApp command.)

For Windows systems, these links can be created manually using the MKLINK command, which must be run as a user with permissions to create symbolic links. These manually created links will not be updated when version numbers change, so it may be just as easy to forego the symbolic link and alter your path to include the build/modules/core/.node/node* and build/modules/core/.node/npm* directories (the directory name will include the version number of the tool).

Confirm that node.js has been installed by calling

node -v

Confirm that npm has been installed by calling

npm -v

Related Topics

Was this content helpful?

Log in or register an account to provide feedback


previousnext
 
expand allcollapse all