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 import from @mui/material/colors #528

Closed
fvanwijk opened this issue Nov 29, 2022 · 3 comments
Closed

Cannot import from @mui/material/colors #528

fvanwijk opened this issue Nov 29, 2022 · 3 comments
Labels

Comments

@fvanwijk
Copy link

fvanwijk commented Nov 29, 2022

Description

When you import from @mui/material/colors, on the development server everything works ok, but when you build and run in prod mode, the following error is thrown:

Error: ERR_UNSUPPORTED_DIR_IMPORT /Users/<project-dir>/node_modules/@mui/material/colors

An example repo including steps to reproduce from zero can be found here.

Since the error isn't thrown when when running with only Vite + React + TS (no vite-plugin-ssr), I think this is the right repo to post the issue.

This MUI issue could be related.

Error Stack

Error: ERR_UNSUPPORTED_DIR_IMPORT /Users/<project-dir>/node_modules/@mui/material/colors /Users/<project-dir>/dist/server/assets/_default.page.server.93b8c381.js
    at finalizeResolution (/Users/<project-dir>/node_modules/ts-node/dist-raw/node-internal-modules-esm-resolve.js:362:17)
    at moduleResolve (/Users/<project-dir>/node_modules/ts-node/dist-raw/node-internal-modules-esm-resolve.js:801:10)
    at Object.defaultResolve (/Users/<project-dir>/node_modules/ts-node/dist-raw/node-internal-modules-esm-resolve.js:912:11)
    at /Users/<project-dir>/node_modules/ts-node/src/esm.ts:218:35
    at entrypointFallback (/Users/<project-dir>/node_modules/ts-node/src/esm.ts:168:34)
    at /Users/<project-dir>/node_modules/ts-node/src/esm.ts:217:14
    at addShortCircuitFlag (/Users/<project-dir>/node_modules/ts-node/src/esm.ts:409:21)
    at resolve (/Users/<project-dir>/node_modules/ts-node/src/esm.ts:197:12)
    at resolve (/Users/<project-dir>/node_modules/ts-node/src/child/child-loader.ts:15:39)
    at ESMLoader.resolve (node:internal/modules/esm/loader:580:30)
@brillout
Copy link
Member

I don't think this is related to VPS.

@brillout brillout closed this as not planned Won't fix, can't repro, duplicate, stale Nov 29, 2022
@garronej
Copy link

MUI isn't providing yet a ESM distribution that node cant in type: module can work with.

See issue: mui/material-ui#37335

@brillout
Copy link
Member

brillout commented May 20, 2023

@garronej Thanks for pointing us to that ticket.

In the meantime, a workaround is to use the solution described at https://vite-plugin-ssr.com/common-issues#npm-packages-containing-invalid-code.

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

No branches or pull requests

3 participants