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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

When running preset-safe codemod, I get a Transformation error (Cannot find module '@material-ui/core/modern/colors') #28542

Closed
2 tasks done
nratter opened this issue Sep 22, 2021 · 8 comments
Assignees
Labels
bug 馃悰 Something doesn't work package: codemod Specific to @mui/codemod

Comments

@nratter
Copy link

nratter commented Sep 22, 2021

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 馃槸

When running npx @mui/codemod v5.0.0/preset-safe . I get lots of the following errors...

 ERR /Users/nratter/Development/jerseywatch/nextjs/src/utils/muiNeutralTheme.ts Transformation error (Cannot find module '@material-ui/core/modern/colors' Require stack: - /Users/nratter/.npm/_npx/62df030d7e52d1d4/node_modules/@mui/codemod/node/v5.0.0/optimal-imports.js - /Users/nratter/.npm/_npx/62df030d7e52d1d4/node_modules/@mui/codemod/node/v5.0.0/preset-safe.js - /Users/nratter/.npm/_npx/62df030d7e52d1d4/node_modules/@mui/codemod/node_modules/jscodeshift/src/Worker.js)
Error: Cannot find module '@material-ui/core/modern/colors'
Require stack:
- /Users/nratter/.npm/_npx/62df030d7e52d1d4/node_modules/@mui/codemod/node/v5.0.0/optimal-imports.js
- /Users/nratter/.npm/_npx/62df030d7e52d1d4/node_modules/@mui/codemod/node/v5.0.0/preset-safe.js

I'm getting this error for every file where I'm importing a color from @material-ui/core... in this particular file muiNeutralTheme.ts, I'm importing blueGrey color using the following line...

import blueGrey from "@material-ui/core/colors/blueGrey";

Consequently, the codemod script seems to hang and these color import lines do not get migrated to import from @mui/material

Expected Behavior 馃

Expect it to migrate without error

Steps to Reproduce 馃暪

Follow the steps in the v4 to v5 migration for 5.0.1

Your Environment 馃寧

`npx @mui/envinfo`
System:
    OS: macOS 10.15.7
  Binaries:
    Node: 14.15.1 - ~/.nvm/versions/node/v14.15.1/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 7.20.6 - ~/.nvm/versions/node/v14.15.1/bin/npm
  Browsers:
    Chrome: 93.0.4577.82
    Edge: 93.0.961.52
    Firefox: 72.0.2
    Safari: 15.0
  npmPackages:
    @emotion/react: ^11.4.1 => 11.4.1
    @emotion/styled: ^11.3.0 => 11.3.0
    @mui/core:  5.0.0-alpha.48
    @mui/icons-material: ^5.0.1 => 5.0.1
    @mui/lab: ^5.0.0-alpha.48 => 5.0.0-alpha.48
    @mui/material: ^5.0.1 => 5.0.1
    @mui/private-theming:  5.0.1
    @mui/styled-engine:  5.0.1
    @mui/styles: ^5.0.1 => 5.0.1
    @mui/system:  5.0.1
    @mui/types:  7.0.0
    @mui/utils:  5.0.1
    @types/react:  17.0.4
    react: ^17.0.2 => 17.0.2
    react-dom: ^17.0.2 => 17.0.2
    typescript: ^4.3.5 => 4.3.5
@nratter nratter added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Sep 22, 2021
@siriwatknp siriwatknp self-assigned this Sep 24, 2021
@siriwatknp
Copy link
Member

@mnajdova I thought we fixed this, do you have any idea?

@siriwatknp siriwatknp added bug 馃悰 Something doesn't work package: codemod Specific to @mui/codemod and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Sep 24, 2021
@guyellis
Copy link

I'm seeing exactly what @nratter is seeing.

@luissardon
Copy link

luissardon commented Oct 1, 2021

I'm also getting the same erros but for multiple core-js modules, when running npx @mui/codemod v5.0.0/preset-safe .

Error: Cannot find module 'core-js/modules/es.array.reduce.js'
Require stack:
- /Users/luissardon/.npm/_npx/67147/lib/node_modules/@mui/codemod/node/util/renameClassKey.js
- /Users/luissardon/.npm/_npx/67147/lib/node_modules/@mui/codemod/node/v5.0.0/collapse-rename-collapsedheight.js
- /Users/luissardon/.npm/_npx/67147/lib/node_modules/@mui/codemod/node/v5.0.0/preset-safe.js
- /Users/luissardon/.npm/_npx/67147/lib/node_modules/@mui/codemod/node_modules/jscodeshift/src/Worker.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at Object.<anonymous> (/Users/luissardon/.npm/_npx/67147/lib/node_modules/@mui/codemod/node/util/renameClassKey.js:3:1)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Module._compile (/Users/luissardon/.npm/_npx/67147/lib/node_modules/@mui/codemod/node_modules/pirates/lib/index.js:99:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Object.newLoader [as .js] (/Users/luissardon/.npm/_npx/67147/lib/node_modules/@mui/codemod/node_modules/pirates/lib/index.js:104:7)
    at Module.load (internal/modules/cjs/loader.js:950:32) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/luissardon/.npm/_npx/67147/lib/node_modules/@mui/codemod/node/util/renameClassKey.js',
    '/Users/luissardon/.npm/_npx/67147/lib/node_modules/@mui/codemod/node/v5.0.0/collapse-rename-collapsedheight.js',
    '/Users/luissardon/.npm/_npx/67147/lib/node_modules/@mui/codemod/node/v5.0.0/preset-safe.js',
    '/Users/luissardon/.npm/_npx/67147/lib/node_modules/@mui/codemod/node_modules/jscodeshift/src/Worker.js'
  ]
}

@siriwatknp
Copy link
Member

@nratter, @guyellis, @luissardon May I ask

  1. What version of @material-ui/core that you used before the migration?
  2. Did you remove the package @material-ui/core before the migration?

@guyellis
Copy link

guyellis commented Oct 3, 2021

@siriwatknp 1. from my package.json:

    "@material-ui/core": "4.12.3",
    "@material-ui/icons": "4.11.2",
  1. I'm fairly certain that I did not remove @material-ui/core before running that codemod.

@siriwatknp
Copy link
Member

This is fixed by #28812

@alainib
Copy link

alainib commented Jan 31, 2022

i still get this error. how to solve it please ?

@mnajdova
Copy link
Member

mnajdova commented Feb 1, 2022

@alainib are you using the latest version of the codemod package?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 馃悰 Something doesn't work package: codemod Specific to @mui/codemod
Projects
None yet
Development

No branches or pull requests

6 participants