ERR_REQUIRE_ESM when removing Tailwind in favor of Sass+Boostrap

I followed the instructions here for removing Tailwind and adding Sass + Bootstrap. (Note #2 was ignored since I don’t see the linter file anywhere.)

When I run yarn build I get:

❯ yarn build
yarn run v1.22.17
$ bud build
:heavy_multiplication_x: Error [ERR_REQUIRE_ESM]: require() of ES Module [secure]/node_modules/@roots/bud-sass/lib/index.js from [secure]/node_modules/@roots/bud-extensions/lib/cjs/Extensions/extensions.service.js not supported.
Instead change the require of index.js in [secure]/node_modules/@roots/bud-extensions/lib/cjs/Extensions/extensions.service.js to a dynamic import() which is available in all CommonJS modules.
at [secure]/node_modules/@roots/bud-extensions/lib/cjs/Extensions/extensions.service.js:116:80
at async Extensions.importExtension ([secure]/node_modules/@roots/bud-extensions/lib/cjs/Extensions/extensions.service.js:116:32)
at async [secure]/node_modules/@roots/bud-extensions/lib/cjs/Extensions/extensions.service.js:99:17
at async Promise.all (index 0)
at async Extensions.injectExtensions ([secure]/node_modules/@roots/bud-extensions/lib/cjs/Extensions/extensions.service.js:98:13)
at async Extensions.booted ([secure]/node_modules/@roots/bud-extensions/lib/cjs/Extensions/extensions.service.js:81:9)
at async [secure]/node_modules/@roots/bud-framework/lib/cjs/Framework/lifecycle/index.js:57:13
at async Promise.all (index 0)
at async [secure]/node_modules/@roots/bud-framework/lib/cjs/Framework/lifecycle/index.js:52:9
at async Bud.lifecycle ([secure]/node_modules/@roots/bud-framework/lib/cjs/Framework/lifecycle/index.js:47:5)
at async factory ([secure]/node_modules/@roots/bud/lib/cjs/factory/index.js:62:5)
at async BuildCommand.execute ([secure]/node_modules/@roots/bud/lib/cjs/cli/commands/build.js:240:20)
at async BuildCommand.validateAndExecute ([secure]/node_modules/clipanion/lib/advanced/Command.js:67:26)
at async Cli.run ([secure]/node_modules/clipanion/lib/advanced/Cli.js:222:24)
at async Cli.runExit ([secure]/node_modules/clipanion/lib/advanced/Cli.js:231:28)

:sparkles: Done in 1.35s.

How to resolve? Thanks

Likely your dependencies are mismatched. It looks to me like @roots/bud-extensions is trying to require @roots/bud-sass when it needs to import it.

I’m willing to wager @roots/bud is at a version 5.x.x and @roots/bud-sass is at a version 6.x.x. Since v6.0.0 was the version which transitioned bud packages from using require to import.

To fix, upgrade @roots/bud to match the version of @roots/bud-sass Or, downgrade @roots/bud-sass to match @roots/bud. Either way, the important thing is that all @roots organization packages are on the same version.

2 Likes

Thanks Kelly. I also had to update @roots/sage from 5.x to match (received a “undefined boot error” before doing that).

For posterity, here’s the relevant section updated in package.json:

“devDependencies”: {
@popperjs/core”: “^2.11.5”,
@roots/bud”: “^6.2.0”,
@roots/bud-sass”: “^6.2.0”,
@roots/sage”: “^6.2.0”,
“bootstrap”: “^5.1.3”
}

1 Like