Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module @swc/helpers (...) #1486

Closed
brunos3d opened this issue Oct 3, 2023 · 3 comments
Closed

Cannot find module @swc/helpers (...) #1486

brunos3d opened this issue Oct 3, 2023 · 3 comments
Assignees

Comments

@brunos3d
Copy link
Contributor

brunos3d commented Oct 3, 2023

Hello, folks. We recently merged the Unify PR in which introduces some important updates to our project, we still fixing some reports, you may already saw the following error with @swc/helpers when using @module-federation/node or @module-federation/nextjs-mf:

Error: Cannot find module '@swc/helpers/_/_interop_require_default'
[2] Require stack:
[2] - /nextjs-v12/node_modules/@module-federation/enhanced/src/index.js
[2] - /nextjs-v12/node_modules/@module-federation/nextjs-mf/src/plugins/NextFederationPlugin/next-fragments.js
[2] - /nextjs-v12/node_modules/@module-federation/nextjs-mf/src/plugins/NextFederationPlugin/index.js
[2] - /nextjs-v12/node_modules/@module-federation/nextjs-mf/src/index.js
[2] - /nextjs-v12/shop/next.config.js
[2]     at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
[2]     at mod._resolveFilename (/nextjs-v12/node_modules/next/dist/build/webpack/require-hook.js:27:32)
[2]     at mod._resolveFilename (/nextjs-v12/node_modules/next/dist/build/webpack/require-hook.js:27:32)
[2]     at Module._load (node:internal/modules/cjs/loader:922:27)
[2]     at Module.require (node:internal/modules/cjs/loader:1143:19)
[2]     at require (node:internal/modules/cjs/helpers:119:18)
[2]     at Object.<anonymous> (/nextjs-v12/node_modules/@module-federation/enhanced/src/index.js:34:34)
[2]     at Module._compile (node:internal/modules/cjs/loader:1256:14)
[2]     at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
[2]     at Module.load (node:internal/modules/cjs/loader:1119:32) {
[2]   code: 'MODULE_NOT_FOUND',
[2]   requireStack: [
[2]     '/nextjs-v12/node_modules/@module-federation/enhanced/src/index.js',
[2]     '/nextjs-v12/node_modules/@module-federation/nextjs-mf/src/plugins/NextFederationPlugin/next-fragments.js',
[2]     '/nextjs-v12/node_modules/@module-federation/nextjs-mf/src/plugins/NextFederationPlugin/index.js',
[2]     '/nextjs-v12/node_modules/@module-federation/nextjs-mf/src/index.js',
[2]     '/nextjs-v12/shop/next.config.js'
[2]   ]
[2] }

This is a known issue and we are working on it, you can track the progress here.

How to fix it

To fix the error, you need to install the @swc/helpers package manually, you can do it by running the following command:

npm install @swc/helpers

Tasks

Preview Give feedback
No tasks being tracked yet.
@brunos3d brunos3d self-assigned this Oct 3, 2023
@ScriptedAlchemy
Copy link
Member

this looks related to module interop needed for TS to properly import anything that uses module.exports

@RussellCanfield
Copy link
Contributor

I believe you can set a config in swc to embed helpers, this prevents needing to install it as a dependency. Called “external helpers”

@ScriptedAlchemy
Copy link
Member

Ive set external helpers to false as this will cause issues with anything entering the webpack runtime (like delegate module or something)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants