Skip to content

Documentation build fails: "require is not defined in ES module scope" #7347

@afarber

Description

@afarber

The npm run docs command fails in CI with:

ReferenceError: require is not defined in ES module scope, you can use import instead

This file is being treated as an ES module because it has a '.js' file extension and '/home/runner/work/osrm-backend/osrm-backend/package.json' contains "type": "module".

Root cause: #7233 added "type": "module" to package.json. The docs build uses Babel to transpile docbox's files to CommonJS, but Node.js still treats the .js output as ESM.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions