#Using a node package in `Run Script`

6 messages · Page 1 of 1 (latest)

tardy pecan
#

I have added a node package to my Dockerfile and have updated FLOWS_EXEC_ALLOWED_MODULES to allow that package, but when I use it in a Run Script operation, I get the following error:

  "message": "'import' and 'export' may appear only with 'sourceType: module'"
}```
Has anyone seen this before? Screenshot of the module being available below:
zenith ridgeBOT
#

Thanks for posting! This is a community powered server, so you may or may not get an answer based on available help and expertise. To increase your chances of somebody being able to help you, please help us help you making sure you:

  • Adding an explanation of exactly what you're trying to achieve.
  • Adding any and all related code or previous attempts.
  • Describing the exact issue or error you are facing.
  • Posting any screenshots if applicable.
  • Reading through https://stackoverflow.com/help/how-to-ask.

When you're done with this thread, please close it. Thanks! ✨

(If you have a support agreement and need help, please contact the core team via email.)

green grove
#

RunScripts run as cjs code so you would have to use require('my-module'). Additionally, we will soon move away from allowing modules in runScript, instead you should write your own operation extension if you want to use modules.

stone ruin
#

(a tutorial on how to do that is coming!)

tardy pecan
#

@green grove in just 10.x or also in 9.x?

green grove
#

We only support the latest version of Directus so no security fixes in 9.x which means this change will happen on the latest 10.x version.