1

I get this error shown in the browser, when trying to create an Code-Editor with HTML and the JavaScript Library 'CodeMirror':

Uncaught ReferenceError: CodeMirror is not defined
    at index.html?_ijt=2cf0kfsr3jnpb58d7jndumktte:68

But considering, that I linked then in my index.html, I am unable to figure out whats wrong:

<!--  CodeMirror  -->
    <link rel="stylesheet" href="codemirror/CodeMirror-master/CodeMirror-master/lib/codemirror.css">
    <script type="module" src="codemirror/CodeMirror-master/CodeMirror-master/src/codemirror.js"></script>
    <script type="module" src="codemirror/CodeMirror-master/CodeMirror-master/mode/javascript/javascript.js"></script>

Do I have to use node.js if I want to include this library in my code?

EDIT:

I changed the files which I added to another version and now only receive one error:

Uncaught ReferenceError: CodeMirror is not defined
    at index.html?_ijt=knaua520sd7qi1kst4958cmse4:74

HTML-Code:

    <link rel="stylesheet" href="codemirror/codemirror-5.61.0/lib/codemirror.css">
    <script type="module" src="codemirror/codemirror-5.61.0/lib/codemirror.js"></script>
    <script type="module" src="codemirror/codemirror-5.61.0/mode/javascript/javascript.js"></script>
  • Thanks for your response. I am facing a similar issue and I have posted it here: https://stackoverflow.com/q/69430941/7584240 If you get a chance can you please have a look and provide some resolution. – BATMAN_2008 Oct 04 '21 at 05:53

1 Answers1

0

I fixed the issue:

<link rel="stylesheet" href="codemirror/codemirror-5.61.0/lib/codemirror.css">
    <script src="codemirror/codemirror-5.61.0/lib/codemirror.js"></script>
    <script src="codemirror/codemirror-5.61.0/mode/javascript/javascript.js"></script>

So, to fix this, you have to either make type="text/javascript" or to remove this parameter, because this is it's default value.

  • Thanks for your response. I am facing a similar issue and I have posted it here: https://stackoverflow.com/q/69430941/7584240 If you get a chance can you please have a look and provide some resolution. – BATMAN_2008 Oct 04 '21 at 05:53