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

with-msw example crashes with ERR_UNSUPPORTED_DIR_IMPORT error #43221

Closed
1 task done
watch-janick opened this issue Nov 22, 2022 · 2 comments · Fixed by #43224
Closed
1 task done

with-msw example crashes with ERR_UNSUPPORTED_DIR_IMPORT error #43221

watch-janick opened this issue Nov 22, 2022 · 2 comments · Fixed by #43224
Labels
examples Issue was opened via the examples template.

Comments

@watch-janick
Copy link

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 21.6.0: Mon Aug 22 20:19:52 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T6000
Binaries:
Node: 18.7.0
npm: 8.15.0
Yarn: 1.22.18
pnpm: 7.17.0
Relevant packages:
next: 13.0.5-canary.4
eslint-config-next: N/A
react: 18.2.0
react-dom: 18.2.0

Which example does this report relate to?

with-msw

What browser are you using? (if relevant)

Chrome 107.0.5304.87 (Official Build) (arm64)

How are you deploying your application? (if relevant)

next dev

Describe the Bug

This error shows up when accessing http://localhost:3000:

error - unhandledRejection: Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import './with-msw-app/node_modules/@mswjs/interceptors/lib/interceptors/ClientRequest' is not supported resolving ES modules imported from ./with-msw-app/node_modules/msw/lib/node/index.mjs
Did you mean to import @mswjs/interceptors/lib/interceptors/ClientRequest/index.js?
    at new NodeError (node:internal/errors:387:5)
    at finalizeResolution (node:internal/modules/esm/resolve:400:17)
    at moduleResolve (node:internal/modules/esm/resolve:965:10)
    at defaultResolve (node:internal/modules/esm/resolve:1173:11)
    at nextResolve (node:internal/modules/esm/loader:173:28)
    at ESMLoader.resolve (node:internal/modules/esm/loader:852:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:439:18)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:40)
    at link (node:internal/modules/esm/module_job:75:36) {
  code: 'ERR_UNSUPPORTED_DIR_IMPORT',
  url: 'file:///with-msw-app/node_modules/@mswjs/interceptors/lib/interceptors/ClientRequest'
}

Expected Behavior

No error should be displayed when accessing http://localhost:3000 and MSW should intercept the first render request (couldn't test it).

To Reproduce

  1. npx create-next-app --example with-msw with-msw-app
  2. cd with-msw-app
  3. yarn dev

You should see the error message in the console when trying to access http://localhost:3000.

@watch-janick watch-janick added the examples Issue was opened via the examples template. label Nov 22, 2022
@watch-janick watch-janick changed the title with-msw example doesn't work at all with-msw example crashes with ERR_UNSUPPORTED_DIR_IMPORT error Nov 22, 2022
@balazsorban44
Copy link
Member

Duplicate of #40904 (comment) but this can now be addressed as it has been fixed upstream.

jankaifer pushed a commit to jankaifer/next.js that referenced this issue Nov 23, 2022
@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
examples Issue was opened via the examples template.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants