79336646

Date: 2025-01-07 16:22:32
Score: 1
Natty:
Report link

Currently having an ESM-Project that shall read text-like files (html / handlebars) - I have activated support for require() just for the case of loading those files.

This is working for me:

import Module from "node:module";

const require = Module.createRequire(import.meta.url);

const templates={
    test: require('./test.handlebars')()
}

console.log('File output: ', templates.test)

Example Code executed

Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: David Renner