react-codemirror2
react-codemirror2 copied to clipboard
Getting "cm is not a function" in NextJs
Hi, I am getting the below error in NextJs. I have tried downgrading the version but it is not getting resolved. Please help!
The versions I have tried - v7.2.1 (latest) v7.1.0 v7.0.0 v6.0.1
Unhandled Runtime Error
TypeError: cm is not a function
Call Stack
Controlled.componentDidMount
node_modules\react-codemirror2\index.js (498:0)
commitLayoutEffectOnFiber
node_modules\react-dom\cjs\react-dom.development.js (23305:0)
commitLayoutMountEffects_complete
node_modules\react-dom\cjs\react-dom.development.js (24688:0)
commitLayoutEffects_begin
node_modules\react-dom\cjs\react-dom.development.js (24674:0)
commitLayoutEffects
node_modules\react-dom\cjs\react-dom.development.js (24612:0)
I have the same problem.
Uncaught TypeError: cm is not a function
I encountered this problem on react18. When react17 was executed, no error was reported, is also nextjs.
i saw this on error page
var React = require('react');
var SERVER_RENDERED = typeof navigator === 'undefined' || global['PREVENT_CODEMIRROR_RENDER'] === true;
var cm;
if (!SERVER_RENDERED) {
cm = require('codemirror');
}
solution - get codemirror@5
I had same problem: "react-codemirror2": "^8.0.0", "react": "^18.2.0", "codemirror": "^6.0.1",
Error goes away when i uninstall install codemirror and install codemirror@5 -- which gets me to
"codemirror": "^5.65.16"