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

Getting "cm is not a function" in NextJs #298

Open
Vasu7389 opened this issue Feb 17, 2023 · 4 comments
Open

Getting "cm is not a function" in NextJs #298

Vasu7389 opened this issue Feb 17, 2023 · 4 comments

Comments

@Vasu7389
Copy link

Vasu7389 commented Feb 17, 2023

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)
@b7wch
Copy link

b7wch commented Mar 14, 2023

I have the same problem.

Uncaught TypeError: cm is not a function

@shmjiao
Copy link

shmjiao commented Mar 31, 2023

I encountered this problem on react18. When react17 was executed, no error was reported, is also nextjs.

@ruanjiayou
Copy link

ruanjiayou commented Apr 13, 2023

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');
}

@filip-savic-bm
Copy link

filip-savic-bm commented Apr 22, 2024

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants