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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read property 'attach' of undefined at attach #19005

Closed
aravinda-arkaje opened this issue Dec 28, 2019 · 36 comments · Fixed by #19042
Closed

TypeError: Cannot read property 'attach' of undefined at attach #19005

aravinda-arkaje opened this issue Dec 28, 2019 · 36 comments · Fixed by #19042
Labels
external dependency Blocked by external dependency, we can’t do anything about it

Comments

@aravinda-arkaje
Copy link

Screenshot from 2019-12-28 14-31-08

Can someone help me out with this issue! When I npm start these arrises.
I have tried with changing the material_ui versions also.

@mkraenz
Copy link

mkraenz commented Dec 28, 2019

Experiencing this as well. My package.json specified multiple dependencies as latest, so it broke after an npm install.

It works however, if I install dependencies with my previous package-lock.json via npm ci.

Seemingly an issue when jumping from

    "@material-ui/core": {
      "version": "4.8.0",

to

   "@material-ui/core": {
      "version": "4.8.1",

Edit: Can confirm now that the error got fixed by editing package.json to use 4.8.0

        "@material-ui/core": "4.8.0",

Then remove node_modules and run npm install again.

Side note: I ran into caching issues with next.js. So be sure to delete build folders like .next before running your app again after you fixed the version to 4.8.0.

@yoyooyooo
Copy link
Contributor

same issue. everything is ok yesterday. then today this issue come. I'm sure my code have no problem. I think the cause of this issue is about dependencies because when i add yesterday's yarn.lock back.everything is ok .

@brightlkms
Copy link

hi if you didn't fix the issue, you should try rendering components without Box component. I replaced my Box components with div tag and things got resolved.

@un3solka
Copy link

Add "jss": "10.0.0" to dependencies. It is a temporary fix.

@un3solka
Copy link

same issue. everything is ok yesterday. then today this issue come. I'm sure my code have no problem. I think the cause of this issue is about dependencies because when i add yesterday's yarn.lock back.everything is ok .

jss was updater few hours ago

@troydaniels
Copy link

Add "jss": "10.0.0" to dependencies. It is a temporary fix.

Thanks @un3solka
Can confirm this temp fix works for me, whereas the others in this thread unfortunately did not

@kishanio
Copy link

Grrr removing Box works though it breaks my styles.

@code-castle-01
Copy link

code-castle-01 commented Dec 28, 2019

Grrr eliminando Box funciona aunque rompe mis estilos.

Si lo hice y funciono !!! Lo bueno es que ya le habia dado estilo a los Box asi que no se rompio nada....

@dinumihnea
Copy link

Downgrade to an older specific version (4.7.2 in my case, without ^) and install using an older version of package.lock.json (version before the upgrade) worked for me, as a temporary fix.

@code-castle-01
Copy link

hola si no solucionó el problema, debe intentar renderizar componentes sin el componente Box. Reemplacé mis componentes Box con div tag y las cosas se resolvieron.

Funciono para mi !

@kishanio
Copy link

Grrr eliminando Box funciona aunque rompe mis estilos.

Si lo hice y funciono !!! Lo bueno es que ya le habia dado estilo a los Box asi que no se rompio nada....

la caja viene con algunos estilos y prefijos predeterminados que se rompieron

@oliviertassinari oliviertassinari added the status: waiting for author Issue with insufficient information label Dec 28, 2019
@oliviertassinari
Copy link
Member

Please provide a full reproduction test case. This would help a lot 👷 .
A live example would be perfect. This codesandbox.io template may be a good starting point. Thank you!

@heshamnaim
Copy link

Above workarounds didn't work for me. I went into makeStyles.js:138 and changed it from

dynamicSheet.update(props).attach();

to

dynamicSheet.update(props)
dynamicSheet.attach()

That fixed it for me. Seems the initial call to update is returning undefined.

@Janpot
Copy link
Member

Janpot commented Dec 28, 2019

@oliviertassinari there you go https://codesandbox.io/s/snowy-sunset-q3fgg
Basically breaks on the next.js example + Box component

Just skimmed this, but it looks like JSS docs seem to do

dynamicSheet.attach().update(props);

instead

@oliviertassinari oliviertassinari removed the status: waiting for author Issue with insufficient information label Dec 28, 2019
@alfonmga
Copy link

alfonmga commented Dec 28, 2019

For those using yarn the only solution that worked for me is to add a resolutions field to my package.json targeting jss 10.0.0 version.

It should look like this:

// package.json

{

  "dependencies": {
    "@material-ui/core": "^4.8.1",
 
  },
  "resolutions": {
    "jss": "10.0.0"
  }
}

@hiagopdutra
Copy link

For those using yarn the only solution that worked for me is to add a resolutions field to my package.json targeting jss 10.0.0 version.

It should look like this:

// package.json

{

  "dependencies": {
    "@material-ui/core": "^4.8.1",
 
  },
  "resolutions": {
    "jss": "10.0.0"
  }
}

Thank you soo much! You save my day!

@Janpot
Copy link
Member

Janpot commented Dec 28, 2019

cross reference: cssinjs/jss#1249

@emilpriver
Copy link

For those using yarn the only solution that worked for me is to add a resolutions field to my package.json targeting jss 10.0.0 version.

It should look like this:

// package.json

{

  "dependencies": {
    "@material-ui/core": "^4.8.1",
 
  },
  "resolutions": {
    "jss": "10.0.0"
  }
}

THANK YOU <3

@eps1lon eps1lon added the external dependency Blocked by external dependency, we can’t do anything about it label Dec 29, 2019
nl0 added a commit to quiltdata/quilt that referenced this issue Dec 29, 2019
nl0 added a commit to quiltdata/quilt that referenced this issue Dec 29, 2019
@KASOGIT
Copy link

KASOGIT commented Dec 29, 2019

I'm using lerna and all the workaround listed above aren’t working for me :/ Should i fix the @material-ui/styles's package version too ?

@Cvijo
Copy link

Cvijo commented Dec 29, 2019

the same issue for me too, I tired with "@material-ui/core": "^4.8.0" delete node_moduels ... npm install and the same error after npm run dev
Cannot read property 'attach' of undefined

@Bessonov
Copy link

Temporary fix with pnpm:

cat <<EOF >> pnpmfile.js
module.exports = {
  hooks: {
    readPackage
  }
}

function readPackage(pkg) {
  if (pkg.dependencies && pkg.dependencies.jss) {
    pkg.dependencies.jss = '10.0.0'
  }
  return pkg
}
EOF

Then remove node_modules and install again.

@mwskwong
Copy link
Contributor

mwskwong commented Dec 30, 2019

@oliviertassinari there you go https://codesandbox.io/s/snowy-sunset-q3fgg
Basically breaks on the next.js example + Box component

Just skimmed this, but it looks like JSS docs seem to do

dynamicSheet.attach().update(props);

instead

Above workarounds didn't work for me. I went into makeStyles.js:138 and changed it from

dynamicSheet.update(props).attach();

to

dynamicSheet.update(props)
dynamicSheet.attach()

That fixed it for me. Seems the initial call to update is returning undefined.

Perhaps create a pull request for hotfix?

Basically what happened is the new version of jss (v10.0.1) which has been released not long ago has somehow broken material-ui. Just downgrade jss to 10.0.0 for tempory fix.

Or:

For those using yarn the only solution that worked for me is to add a resolutions field to my package.json targeting jss 10.0.0 version.

It should look like this:

// package.json

{

  "dependencies": {
    "@material-ui/core": "^4.8.1",
 
  },
  "resolutions": {
    "jss": "10.0.0"
  }
}

Then run yarn install

@comsky
Copy link

comsky commented Dec 30, 2019

Facing the same issue when I upgrade my yarn version 1.17.0 to 1.21.1.
There was no error with 1.17.0 version.

package.json:
"@material-ui/core": "^4.4.0"
"@material-ui/styles": "^4.3.3"

@whck6
Copy link

whck6 commented Dec 30, 2019

I meet the same issues but i solved.

"@material-ui/core": "4.1.0",
"@material-ui/styles": "4.4.1",

@davalapar
Copy link

davalapar commented Dec 30, 2019

appending the following solved it for me, but i've got no idea what's specifically causing this 😕

  "resolutions": {
    "jss": "10.0.0"
  }

edit: ah yeah probably this:

cssinjs/jss#1249 (comment):
this is a breaking change:
https://github.com/cssinjs/jss/pull/1242/files#diff-29aac1ba5d08e188c14800bc889c5474L186
sheet.update used to return this, now it returns undefined

hence [email protected] is breaking it but [email protected] isn't

@popuguytheparrot
Copy link

popuguytheparrot commented Dec 30, 2019

I tried use resulotions, but got warning:
warning Resolution field "[email protected]" is incompatible with requested version "[email protected]"
and yarn.lock dont change jss version

@favna
Copy link
Contributor

favna commented Dec 30, 2019

Adding resolutions worked for us, as an extra security we also set material-ui/core to 4.8.0.


@popuguytheparrot ensure your package.json is your source of truth: rm -rf node_modules yarn.lock && yarn cache clean && yarn. This removes node_modules and yarn.lock then clears the yarn cache and reinstalls from package.json. (note: will not work as a copypaste on Windows Powershell/CMD, this is a bash command). The warnings will still come, but warnings are just that, warnings. Not errors.

@mceIdo
Copy link
Contributor

mceIdo commented Dec 30, 2019

@davalapar thanks for the reference - just submitted a PR #19042

@popuguytheparrot
Copy link

@favna what about of these packages?
"@material-ui/core": "",
"@material-ui/icons": "",
"@material-ui/lab": "",
"@material-ui/styles": "",
"@material-ui/system": "",

@favna
Copy link
Contributor

favna commented Dec 30, 2019

@popuguytheparrot Just core matters, not the rest.

@aruprakshit
Copy link

I got exactly same error.. I have

    "@material-ui/core": "^4.8.1",
    "@material-ui/icons": "^4.5.1",

@mwskwong
Copy link
Contributor

mwskwong commented Dec 30, 2019

@popuguytheparrot This warning is expected. Just run yarn install and you will be fine.

@popuguytheparrot
Copy link

@matthewkwong2 same result

@minhna
Copy link

minhna commented Dec 30, 2019

npm install [email protected] temporary fixed, at least for me.

@oliviertassinari
Copy link
Member

Released under v4.8.2.

@Olaide-EO
Copy link

hi if you didn't fix the issue, you should try rendering components without Box component. I replaced my Box components with div tag and things got resolved.

This worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external dependency Blocked by external dependency, we can’t do anything about it
Projects
None yet
Development

Successfully merging a pull request may close this issue.