Skip to content

Fix ESM compatibility for 'webdav' package in CommonJS context #751

@CapoMK25

Description

@CapoMK25

ESM webdav package not working with NestJS setup using CommonJS. This blocks npm run start:dev from working out of the gate with the default code.

`[8:35:17 PM] Starting compilation in watch mode...

[8:35:26 PM] Found 0 errors. Watching for file changes.

[dotenv@17.2.2] injecting env (0) from .env -- tip: ⚙️ specify custom .env file path with { path: '/custom/path/.env' }
C:\Users\Matias.DESKTOP-2SBTD6B\Desktop\Altzone-Server\dist\gameAnalytics\logFile.service.js:19
const webdav_1 = require("webdav");
^

Error [ERR_REQUIRE_ESM]: require() of ES Module C:\Users\Matias.DESKTOP-2SBTD6B\Desktop\Altzone-Server\node_modules\webdav\dist\node\index.js from C:\Users\Matias.DESKTOP-2SBTD6B\Desktop\Altzone-Server\dist\gameAnalytics\logFile.service.js not supported.
Instead change the require of index.js in C:\Users\Matias.DESKTOP-2SBTD6B\Desktop\Altzone-Server\dist\gameAnalytics\logFile.service.js to a dynamic import() which is available in all CommonJS modules.
at Object. (C:\Users\Matias.DESKTOP-2SBTD6B\Desktop\Altzone-Server\dist\gameAnalytics\logFile.service.js:19:18) {
code: 'ERR_REQUIRE_ESM'
}

Node.js v20.11.0

This is the error output. The fix has already been done by me. This issue is just for documentation purposes.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions