How to write params to ArduPilot (APM) from NodeJS using node-mavlink? For example to change geofence enable?
You should read the documentation for the mavlink parameter protocol here: http://qgroundcontrol.org/mavlink/parameter_protocol
The basic idea is that you send a PARAM_SET message to set a parameter value, then wait for an ACK in the form of a PARAM_VALUE message that has the value you just set.

The documentation for the PARAM_SET and PARAM_VALUE messages is in the mavlink defintion XML file: https://github.com/omcaree/node-mavlink/blob/c30f8a63ca6a1ebc1669fefcd07bb3780540e41b/src/mavlink/message_definitions/v1.0/common.xml#L966
Here's an (untested) example of creating and sending a PARAM_SET message to enable the geofence.
I checked the ArduCopter/APM:Copter parameter documentation to learn that the parameter you want is called FENCE_ENABLE, and that a value of 1 means it's enabled. I checked the mavlink message definition for the MAV_PARAM_TYPE enum to learn the enum value for the param_type argument to specify a UINT_8 (my best guess for the type of a boolean parameter).
myMAV.createMessage(
"PARAM_SET",
{
'target_system': 1,
'target_component': 1,
'param_id': 'FENCE_ENABLE',
'param_value': 1.0,
'param_type': 1
},
function(message) {
serialport.write(message.buffer);
});
(See the "Initialization" section of the node-mavlink documentation for information on how to load and initialize the library.)
I haven't written the code to receive the ACK from the drone, but the "Parsing Data" section of the documentation will guide you on how to do that.