[javascript] How do you share constants in NodeJS modules?

As an alternative, you can group your "constant" values in a local object, and export a function that returns a shallow clone of this object.

var constants = { FOO: "foo" }

module.exports = function() {
  return Object.assign({}, constants)
}

Then it doesn't matter if someone re-assigns FOO because it will only affect their local copy.