This topic is under construction for the 18.2 release of LabKey Server.Starting in 17.2 LabKey Server has taken a dependency on
Node.js and the node package manager (npm).
Module Developers
If you already have a package.json declared at the root of your module, our build currently requires certain "scripts" targets be available, namely:
- build
- build-prod
- clean
- setup (not required in 17.3)
Building LabKey
17.2 through 18.1
For versions of LabKey before 18.2, we recommend installing/upgrading to the latest LTS version (8.x as of this writing) and ensuring you have both node/npm available on your path. Operating system-specific installations are available on the
NPM website.
18.2 and Beyond
As of Release 18.2 (or, more specifically, version 1.3 of the gradlePlugins), 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 avoid potential conflicts with node module versioning, you should remove any existing node_modules directories from your LabKey modules' directories before doing your first build with the 1.3 version. The 1.3 version of gradlePlugin provides a task, cleanNodeModules, that does just this. You can invoke this task at the root level of your enlistment and it will execute the task for all LabKey modules that have a package.json file. Alternatively, you can remove each node_module directory manually.
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 <LABKEY_ROOT>/.node/node/bin and <LABKEY_ROOT>/.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 after updating to version 1.3.)
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/.npm/node*/bin and build/modules/core/.npm/npm*/bin directories.
Related Topics