-
Notifications
You must be signed in to change notification settings - Fork 75
npm and nodejs packages
This page contains various details on how to handle npm and nodejs recipes, and especially the shrinkwrap file.
It applies to any recipe using the npm-online-install.
Here is a copy & paste recipe. Do make sure that patches are applied, in case of signal-server, that is best done by opening packages.json and checking that the venus and ais package are there as mandatory packages.
(the rm -rf ./node_modules is actually not necessary when taking a fresh folder, but nice if you need to do this multiple times somehow)
cd ./build/tmp-glibc/work/ekrano-ve-linux-gnueabi/signalk-server/2.8.3-r0/npm
rm ./npm-shrinkwrap.json
rm -rf ./node_modules
npm install --omit=dev
npm shrinkwrap
cp ./npm-shrinkwrap.json ../../../../../../../sources/meta-victronenergy/meta-third-party/recipes-extended/signalk-server/signalk-server/
cd ../../../../../../../sources/meta-victronenergy/meta-third-party/recipes-extended/signalk-server/signalk-server/
A nice tool to check the up to dateness of all is:
npm outdated
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.
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.
Most important to know, is that this is how its installed:
npm install --arch=xxx --target_arg=xxx --production
That excludes any dev dependencies, and also excludes any optional dependencies.
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: