Scripts not running in Templater

What I’m trying to do

I am trying to use scripts in Templater. Currently, only text and fields eg {{date}} appear as desired in the target file. JavaScript scripts are not running. When I try, the output in the target file is simply the unexecuted code that is meant to produce the output.

Things I have tried

I thought it may be because I didn’t have moment.js installed, so I installed node.js. Moment is showing when checking in the terminal.
I have tried disabling all other community plugins but this has not changed the issue.
I have looked in the developer console and between me and ChatGPT4o we have not identified any relevant messages.
I have checked the paths in the .js files.
I have read the Templater documentation but not found anything relevant.

Any help would be greatly appreciated.