From 962bbc04b5b3a98ccf1fc88d3b0a181262cf7bd0 Mon Sep 17 00:00:00 2001 From: Faruk AYDIN Date: Mon, 8 Jan 2024 12:25:21 +0100 Subject: [PATCH] fix: Change require.resolve to work with ESM --- packages/backend/src/helpers/web-ui-handler.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/helpers/web-ui-handler.js b/packages/backend/src/helpers/web-ui-handler.js index 8d82fe16..4e849a24 100644 --- a/packages/backend/src/helpers/web-ui-handler.js +++ b/packages/backend/src/helpers/web-ui-handler.js @@ -1,11 +1,15 @@ import express from 'express'; import { dirname, join } from 'path'; import appConfig from '../config/app.js'; +import { fileURLToPath } from 'url'; const webUIHandler = async (app) => { if (appConfig.serveWebAppSeparately) return; - const webAppPath = require.resolve('@automatisch/web'); + const moduleURL = new URL('@automatisch/web/package.json', import.meta.url); + const modulePath = fileURLToPath(moduleURL); + const webAppPath = dirname(modulePath); + const webBuildPath = join(dirname(webAppPath), 'build'); const indexHtml = join(dirname(webAppPath), 'build', 'index.html');