Register a module with `node -r my-module/register`

Before Netlify I was registering modules while lanching node command, like this:

node -r my-module/register index.js

This will allow me to use that module in every part of my repo. The most common use of this is

node -r source-map-support/register index.js

I have also tried to set the enviornment variable

NODE_OPTIONS='-r my-module/register'
NODE_OPTIONS='-r node_modules/my-module/register'
NODE_OPTIONS='-r node_modules/my-module/register.js'
NODE_OPTIONS='-r "my-module/register"'
NODE_OPTIONS='--require my-module/register' 

but with no success.

How can I achive this with Netlify?
Should I edit all my files and import it manually?
Why NODE_OPTIONS doesn’t work?

Thank you

After manually importing the module in my function file

import 'my-module/register'

It started working.

I did not understand how the unbundled js functions work. They follow the import in the files and get the modules from the node_modules folder.

Here the doc:

1 Like

Hey there, @ndr4 :wave:

Thank you for coming back and letting us know how you got your solution! This will be very beneficial for future Forums members should they encounter something similar :netlisparkles: