Skip to content

Build fails: Can't resolve 'path' from postman-code-generators - missing polyfill since v4.3.5 #1353

@Preston-Landers

Description

@Preston-Landers

Hi, thanks for this great package! I've run into a build failure that I think might have been introduced when node-polyfill-webpack-plugin was removed in #1081.

Description

The build fails with Module not found: Can't resolve 'path' errors originating from postman-code-generators, which uses require('path') in 13 of its code generators. The theme's configureWebpack in lib/index.js provides fallbacks for buffer and process, but not path.

This affects both the standard webpack bundler and Rspack (experimental_faster: true).

Reproduction

Minimal repro repo: https://github.com/Preston-Landers/docusaurus-openapi-docs-path-browserify-issue

git clone https://github.com/Preston-Landers/docusaurus-openapi-docs-path-browserify-issue.git
cd docusaurus-openapi-docs-path-browserify-issue
npm install
npx docusaurus gen-api-docs all
npm run build

Environment

  • docusaurus-theme-openapi-docs: 4.7.1
  • docusaurus-plugin-openapi-docs: 4.7.1
  • @docusaurus/core: 3.9.2
  • Node: 22+
  • Tested on macOS, Linux, and Windows

Workaround

Adding a custom plugin with the missing fallback resolves the issue:

// docusaurus.config.js
plugins: [
  function nodePathPolyfill() {
    return {
      name: "node-path-polyfill",
      configureWebpack() {
        return {
          resolve: {
            fallback: {
              path: require.resolve("path-browserify"),
            },
          },
        };
      },
    };
  },
  // ... other plugins
],

Suggested fix

Add path: require.resolve("path-browserify") to the resolve.fallback object in both branches of the configureWebpack method in src/index.ts, and add path-browserify as a dependency of the theme package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions