-
-
Notifications
You must be signed in to change notification settings - Fork 151
Installing and Updating Node.js
Starting with Signal K(SK) server version 2.0.0 the recommended Node.js version is 18. 18 is the active LTS (Long Term Support) version in 2023. Node 10 is past its end of life and won't receive any (security) updates.
The best way to upgrade, to Node.js 18, is to start from scratch with a new OS and doing a new SK install, but with some fixes, described below, an existing installation can hopefully be upgraded.
It's highly recommended that you have a backup. This blogpost describes how to create a bootable copy of your existing installation. The method can also be used to create a bootable SSD or USB drive.
Use the following command to check the install
node -v && npm -v
which will report, something like, v18.15.0, 9.5.0
which are the versions of "node" and "npm"
The SK server is updated via SK dashboard or issue the command
sudo npm install -g signalk-server
There will be some warnings shown but no errors should occur.
In a browser use the SK Dashboard to check if it's working. In the box "Connection & Plugin Status" below column "Last Error" red text will report an error.
- delete or rename ~/.signalk/node_modules so that all previous plugin code is not accessible
- run
npm install
in~/.signalk/
to reinstall all plugins
Probably some plugin errors will occur and they are due to the Node upgrade. These plugins must be reinstalled. The plugin with the error will not be visible in the "Appstore => Installed" so we have to uninstall manually.
Uninstall example.
As an example the @signalk/charts-plugin
will stop working due to a SQL change i Node 16. So to uninstall this plugin position yourself in the .signalk
directory with cd ~/.signalk
and then command
sudo npm uninstall @signalk/charts-plugin
and then reinstall the plugin again from the Appstore.
Serial ports.
Other plugins that will fail are the ones using serial ports for example @signalk/vedirect-serial-usb
@signalk/signalk-node-red.
If you are using Node-Red please update to the latest version and be aware of that nodes that use serial ports have to be reinstalled/upgraded. As an example the node node-red-node-serialport
.
node' was compiled against a different Node.js version
In some cases reinstalling the plugins didn't work and the above error was shown. Please test with rename /home/pi/.signalk/node_modules/
and then run npm install
in /home/pi/.signalk/
.
This will install all the plugins, and their dependencies, in /home/pi/.signalk/package.json
.
Other errors.
It could also be that the failed plugin is not updated to use Node 16 and therefore you have to contact the developer. In Appstore at every plugin line there is "I" which you can click on. This will take to the NPM website and at the right you will find "Repository". Click on that link and at Github create an issue.
Under Linux, depending on the migration method, the location of the node
binary may change. It can be located at /usr/bin/node
or /usr/local/bin/node
and sometimes both.
Check the contents of the PATH variable and which version of node
it will use first. If possible clean it up so that you only have one.
If some warnings appear during the Signal K server update, the messages below do not prevent the server from working properly.
- npm WARN deprecated core-js@2.6.12: core-js@<3.4 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
- Node-RED: starting with v2.12.0 uses Node-RED v2 that is no longer supported on Node 10