npm and nodejs packages - victronenergy/venus GitHub Wiki

This page contains various details on how the Venus OS build system handles npm and nodejs recipes, and especially the shrinkwrap file.

Everything described here applies to all recipes using the npm-online-install.bbclass. At this moment, these are:

  • node-red
  • node-red-contrib-victron
  • signalk-server
  • victron-vrm-api

A complete list can always be updated by a simple grep over a Venus OS build system tree.

How to update npm-shrinkwrap

There is a special bitbake task for it, its used like this:

bitbake -c update_shrinkwrap node-red

This was added here

Note that for signalk-server, because there are patches in the recipe, a small work-around is (or was) needed. To know if its no longer needed, just try without building it before running update_shrinkwrap:

[first update the recipe, patches, whatever]
bitbake -c cleanall
bitbake signalk-server    <- this one likely errors out, but is here for purpose of applying patches that are in the recipe 
bitbake -c update_shrinkwrap signalk-server
bitbake signalk-server
[now double check installed versions]

A simple way to check up to dateness of all dependencies is by this tool:

/usr/lib/node_modules/signalk-server# npm outdated
Package                     Current   Wanted  Latest  Location                                 Depended by
@signalk/streams              5.0.6    5.0.6   5.1.1  node_modules/@signalk/streams            signalk-server
baconjs                       1.0.1    1.0.1  3.0.23  node_modules/baconjs                     signalk-server
bcryptjs                      2.4.3    2.4.3   3.0.2  node_modules/bcryptjs                    signalk-server
body-parser                  1.20.3   1.20.3   2.2.0  node_modules/body-parser                 signalk-server
chalk                         3.0.0    3.0.0   5.6.2  node_modules/chalk                       signalk-server
cookie                        0.4.2    0.4.2   1.0.2  node_modules/cookie                      signalk-server
express                      4.21.2   4.21.2   5.1.0  node_modules/express                     signalk-server
file-timestamp-stream         2.2.4    2.2.4   3.0.0  node_modules/file-timestamp-stream       signalk-server
geolib                        3.2.2    3.2.2   3.3.4  node_modules/geolib                      signalk-server
primus                        7.3.5    7.3.5   8.0.9  node_modules/primus                      signalk-server
selfsigned                    2.4.1    2.4.1   3.0.1  node_modules/selfsigned                  signalk-server
serialport                   11.0.1   11.0.1  13.0.0  node_modules/serialport                  signalk-server
signalk-n2kais-to-nmea0183    1.5.0    1.5.0   2.0.3  node_modules/signalk-n2kais-to-nmea0183  signalk-server
swagger-ui-express            4.6.3    4.6.3   5.0.1  node_modules/swagger-ui-express          signalk-server
unzipper                    0.10.14  0.10.14  0.12.3  node_modules/unzipper                    signalk-server
uuid                          8.3.2    8.3.2  13.0.0  node_modules/uuid                        signalk-server
ws                           7.5.10   7.5.10  8.18.3  node_modules/ws                          signalk-server

Caveats about npm and shrinkwrap and such

  1. Don't clone from github to make npm-shrinkwraps!

Beware that cloning the signalk repo from github and then installing and making the npm-shrinkwrap doesn't work and results in issues when building Venus in OE and or only thereafter: signalk-server doesn't run, complaining of missing server-api package and more.

Cloning from github and npm installing results in symlinking to the modules under packages because it uses npm workspaces - mechanism for monorepo = multiple different modules that are interconnected to facilitate developing features that span the sk server proper and the modules it uses

For further info, see also this issue: https://github.com/victronenergy/venus/issues/1298.

  1. When making shrinkwraps by hand, do it in the OE build.

Why? Because for example, different versions of npm result in different layouts of npm-shrinkwrap.json

how does Venus OS build an npm package?

The npm class in OE was so slow, that we made a new implementation, see here: https://github.com/victronenergy/meta-victronenergy/blob/master/meta-third-party/classes/npm-online-install.bbclass

So, any recipe using that class, is built using the code in that file.

npm-shrinkwrap.json and package.json

Each recipe should contain an npm-shrinkwrap.json.

The purpose of having that is having installable builds. Instead of whenever doing a Venus OS build, having the npm installer take the latest versions of all packages according to limitations defined in the package.json file.

If a recipe doesn't have a npm-shrinkwrap.json file, the Venus OS build will fail with a warning about it being missing.

Some work was done to make that work right, see: