运行material-ui codemod时无法找到模块'@material-ui/core/es'错误

ha1*_*gen 6 material-ui jscodeshift

我正在尝试运行top-level-imports此处找到的codemod: https: //github.com/mui-org/material-ui/blob/master/packages/material-ui-codemod/README.md#top-level-imports

所以我运行了npm install -D @material-ui/codemod脚本,然后 find src -name '*.tsx' -print | xargs npx jscodeshift -t node_modules/@material-ui/codemod/lib/v4.0.0/top-level-imports.js 得到以下错误输出:

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. 

Run Code Online (Sandbox Code Playgroud)

以前有人遇到过这种情况吗?

小智 0

我认为问题可能是因为我们正在尝试访问导入说明符,path.node.specifiers它应该path.value.在这里 https://github.com/mui/material-ui/blob/b9423b64a3986fa2f0ed14af38afa3e2de7b07be/packages/mui-codemod/src/v4.0.0 /top-level-imports.js#L28