Reading from constants.js file from HTML in custom node

Hi there, I wanted to do something apparently simple with my custom nodes, create a constants.js file on the same directory(/nodes) where I store all the .html and .js files.
I wanted to access the constants defined in this file from the HTML file of one of my nodes to do some validation, but haven't been able to do it so far.

Any idea on how I could do this? Thanks in advance

Hi @ItsDaveTheWave

In your nodes root folder node-red-contrib-cool-node, add a folder resources
you can then call into this folder like so, in your HTML file

<script src="resources/node-red-contrib-cool-node/constants.js"></script>

Loading extra resources in the editor : Node-RED (


Just remember that file will be accessible to anyone with admin access to your node-red instance. Not a good idea to put anything secret in it! :slight_smile:

1 Like