Skip to content

ReferenceError: module is not defined for @rjsf/core/dist/index.js #4656

@rmaury

Description

@rmaury

Prerequisites

What theme are you using?

validator-ajv8

Version

6.x-beta

Current Behavior

Since a new version that fixes radiobuttons with a default object has been deployed, I wanted to install it. (beta version).
When I install this one, I get an error after the build :
(ReferenceError: module is not defined)

Image

Image

PS: Same error appears for @rjsf/validator-ajv8

If I go back to the 5.x, I no longer have this error.

----------------------------------
UPDATE

One thing I've tried :

Copy/paste @rjsf from node_modules to my current src, and imported components from here like
import Form from "src/custom/@rjsf/core";

=> And everything works from here.

So I think it's an issue when node_modules js file is generated on build, the only one to have an error from all other libs is this one (there is only one "module.exports" error and this is for @rjsf/core/dist/index.js)

----------------------------------

Expected Behavior

I want to be able to install latest version to try the fix for the radio buttons

Steps To Reproduce

yarn add @rjsf/core @rjsf/utils @rjsf/validator-ajv8

It installs ^6.0.0-beta.10 for these libs.

And I use Form in my component with these imports :

import Form from "@rjsf/core";
import validator from "@rjsf/validator-ajv8";

Just in case, this is what looks like my tsconfig :

{
  "compilerOptions": {
    "target": "ESNEXT",
    "module": "commonjs",
    "jsx": "react-jsx",
    "declaration": true,
    "outDir": "./public/build/",
    "strict": true,
    "strictNullChecks": true,
    "strictFunctionTypes": true,
    "moduleResolution": "node",
    "baseUrl": "./",
    "paths": {
      "@*": ["assets/js/*"],
      "@images": ["assets/images"]
    },
    "typeRoots": [
      "./node_modules/@types"
    ] ,
    "types": [
      "node"
    ],
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
    "resolveJsonModule": true
  }
}

And I'm using React 19.1.0

Environment

- OS:Ubuntu
- Node:22
- npm:

Anything else?

Am I doing something wrong ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugneeds triageInitial label given, to be assigned correct labels and assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions