[Solved] Object.fromEntries is not a function error when using chakra-ui and next.js
Next JS
Tarif Hossain
Problem:
Sometimes we use Vercel to create the next.js app and then installed chakra-ui using the following command line:
npm i @chakra-ui/react @emotion/react@^11 @emotion/styled@^11 framer-motion@^4
It resulted in the following error:
TypeError: Object.fromEntries is not a function at inner (/Users/vaibhavverma9/Desktop/tcofrontend/node_modules/@chakra-ui/utils/dist/cjs/walk-object.js:21:21) at /Users/vaibhavverma9/Desktop/tcofrontend/node_modules/@chakra-ui/utils/dist/cjs/walk-object.js:24:22 at Array.map (<anonymous>) at inner (/Users/vaibhavverma9/Desktop/tcofrontend/node_modules/@chakra-ui/utils/dist/cjs/walk-object.js:21:55) at /Users/vaibhavverma9/Desktop/tcofrontend/node_modules/@chakra-ui/utils/dist/cjs/walk-object.js:24:22 at Array.map (<anonymous>) at inner (/Users/vaibhavverma9/Desktop/tcofrontend/node_modules/@chakra-ui/utils/dist/cjs/walk-object.js:21:55) at walkObject (/Users/vaibhavverma9/Desktop/tcofrontend/node_modules/@chakra-ui/utils/dist/cjs/walk-object.js:31:10) at createThemeVars (/Users/vaibhavverma9/Desktop/tcofrontend/node_modules/@chakra-ui/styled-system/dist/cjs/create-theme-vars/create-theme-vars.js:19:25) at toCSSVar (/Users/vaibhavverma9/Desktop/tcofrontend/node_modules/@chakra-ui/styled-system/dist/cjs/create-theme-vars/to-css-var.js:28:64)
Solution 1:
You have to update the node version v10.17.0. I updated it to v14.17.0!
Solution 2:
You can use the quick command with nvm:
nvm install v14
Thanks for reading this article, if you have any questions you can ask in the comment section.