You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm encountering an ERR_UNSUPPORTED_DIR_IMPORT error during server-side rendering (SSR) with Vite, React, MUI (Material UI), and Inertia.js. The specific error message is:
Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import '/var/www/html/myproject/node_modules/@mui/material/utils' is not supported resolving ES modules imported from /var/www/html/myproject/node_modules/@mui/icons-material/esm/utils/createSvgIcon.js
Did you mean to import "@mui/material/node/utils/index.js"?
This error only occurs during the SSR process (php artisan inertia:start-ssr). The client-side build works fine.
Corrected config/inertia.php: I've ensured that the bundle path in my config/inertia.php file correctly points to the SSR bundle generated by Vite (which is now in bootstrap/ssr/ssr.js):
'bundle' => base_path('bootstrap/ssr/ssr.js'),
noExternal Configuration: I've added the relevant MUI packages, lexical packages, react packages and @inertiajs/server to the ssr.noExternal array in my vite.config.js:
I expect the SSR server to start without any ERR_UNSUPPORTED_DIR_IMPORT errors.
Actual Behavior:
The ERR_UNSUPPORTED_DIR_IMPORT error persists, preventing the SSR server from starting.
Question:
How can I resolve the ERR_UNSUPPORTED_DIR_IMPORT error with @mui/material/utils during Vite SSR with Inertia.js? Is there a specific configuration or workaround needed to handle MUI's internal module resolution in this context?
Search keywords:
The text was updated successfully, but these errors were encountered:
I'm encountering an ERR_UNSUPPORTED_DIR_IMPORT error during server-side rendering (SSR) with Vite, React, MUI (Material UI), and Inertia.js. The specific error message is:
This error only occurs during the SSR process (php artisan inertia:start-ssr). The client-side build works fine.
Problem Context:
I'm using the following technologies:
Laravel: 11.38.2
Inertia.js: 2.0.0
React: 19.0.0
MUI (Material UI): 6.4.0
Vite: 6.0.7
Node.js: 22.13.0
npm: 10.9.2
What I've Tried:
Corrected
config/inertia.php
: I've ensured that thebundle
path in myconfig/inertia.php
file correctly points to the SSR bundle generated by Vite (which is now inbootstrap/ssr/ssr.js
):noExternal
Configuration: I've added the relevant MUI packages, lexical packages, react packages and@inertiajs/server
to thessr.noExternal
array in myvite.config.js
:Clean Install: I've tried removing
node_modules
,package-lock.json
, clearing the npm cache, and reinstalling dependencies.Updated MUI: I have updated MUI to the latest version.
Corrected imports in
ssr.jsx
: I have checked my imports in the ssr.jsx file.verified vite config output and ssr output: I have verified the output of the vite config, and the ssr output directory.
Relevant Code Snippets:
vite.config.js
:config/inertia.php
:resources/js/ssr.jsx
:Expected Behavior:
I expect the SSR server to start without any
ERR_UNSUPPORTED_DIR_IMPORT
errors.Actual Behavior:
The
ERR_UNSUPPORTED_DIR_IMPORT
error persists, preventing the SSR server from starting.Question:
How can I resolve the
ERR_UNSUPPORTED_DIR_IMPORT
error with@mui/material/utils
during Vite SSR with Inertia.js? Is there a specific configuration or workaround needed to handle MUI's internal module resolution in this context?Search keywords:
The text was updated successfully, but these errors were encountered: