Error in Accessing Import that is working fine in node.js.
In react, What I'm doing is
import {
experimental_extendTheme as materialExtendTheme,
Experimental_CssVarsProvider as MaterialCssVarsProvider,
THEME_ID as MATERIAL_THEME_ID,
} from '@mui/material/styles'; // IT GIVES ERROR
import CssBaseline from '@mui/material/CssBaseline'; // IT GIVES ERROR
import { CssBaseline } from '@mui/material'; // IT WORKS FINE
error: Directory import /root/.cache/deno/npm/registry.npmjs.org/@mui/material/5.15.6/styles is not supported resolving import from file:///home/user/client/src/main.tsx
Did you mean to import index.js within the directory?
Caused by:
Is a directory (os error 21)
------------------
I've switched from node to deno recently, only some days ago, please someone help me, I've search web, ai, everything, yet tring this for 2 days and still I am not anywhere near solution.
2 Replies
you are trying to import a directory instead of a file
you want to import the actual file (in this case its probably
index.js
)
if you really want directory imports, which we don't recommend, you can specify the --unstable-sloppy-imports
flagthanks for answering friend, But I know this, but this way works in node.js, and I'm indeed using --unstable-sloppy-imports, in deno run.
detail analysis:
/node_modules/@mui/material/styles$ ls | grep -E "index|package"
index.d.ts
index.js
package.json
/node_modules/@mui/material/styles$ cat package.json
{
"sideEffects": false,
"module": "./index.js",
"main": "../node/styles/index.js",
"types": "./index.d.ts"
}
--------------------
As you can see the directory have an index.js and even a package.json that specify the main file, And in node.js I didn't have to specify the fileName, My code base is very large, and I want it to run as it run in node, without changing any file.