How to update nodejs on Jenkins master node?
I would have a look at the Tool Auto-Installation which allows Jenkins to install the tooling you need.


  Lets you configure tools so that agents will install them on demand whenever running a job that needs them. This could be especially useful when running a large farm of agents in a cloud which all start with a minimal operating system configuration.


Speaking of that also checkout the NodeJS Plugin which


  Provides NodeJS auto-installer, allowing to create as many NodeJS installations "profiles" as you want.
  The auto-installer will automatically install a given version of NodeJS, on every jenkins slave where it will be needed
  Allows to install globally some npm packages inside each installations, these npm packages will be made available to the PATH