Cannot find module '@material-ui/core/es' error when running material-ui codemod
Asked Answered
C

1

6

I'm trying to run the top-level-imports codemod found here: https://github.com/mui-org/material-ui/blob/master/packages/material-ui-codemod/README.md#top-level-imports.

So I ran npm install -D @material-ui/codemod and then I ran the script find src -name '*.tsx' -print | xargs npx jscodeshift -t node_modules/@material-ui/codemod/lib/v4.0.0/top-level-imports.js and I get the following error output:

Processing 1 files... 
Spawning 1 workers...
Sending 1 files to free worker...
 ERR ./components/form/TextField.tsx Transformation error (Cannot find module '@material-ui/core/es')
Error: Cannot find module '@material-ui/core/es'
    at Function.Module._resolveFilename (module.js:536:15)
    at Function.resolve (internal/module.js:18:19)
    at transformer (.../node_modules/@material-ui/codemod/lib/v4.0.0/top-level-imports.js:29:54)
All done. 

Has anyone encountered this before?

Characharabanc answered 8/3, 2020 at 6:10 Comment(2)
I have the same issue. Not sure what to do. Did you figure it out?Usn
No I didn't, but I realized that this shouldn't be an issue if you are using tree-shaking with Webpack. So I didn't bother updating my imports.Characharabanc
I
0

I assume the issue might be because we are trying to access the import specifiers from path.node.specifiers instead it should be path.value. here https://github.com/mui/material-ui/blob/b9423b64a3986fa2f0ed14af38afa3e2de7b07be/packages/mui-codemod/src/v4.0.0/top-level-imports.js#L28

Immersed answered 18/1, 2023 at 6:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.