question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

problem with importing codemirror

See original GitHub issue
Tell me about your development environment.
  • Node version: v8.9.3
  • NPM version: 6.4.1
  • Operating System: Windows 10
Describe the issue / bug.

hello I’m struggling with problem. I want to use this template with codemirror library. I have created clean project and everything I’ve done is replacing LandingPage.vue file with following content:

<template>
    <div id="wrapper">
        <textarea ref="ed" id="editor">
import someResource from 'codemirror/some-resource'
export default {
  data () {
    return {
      exampleCode: 'const a = 10'
  }
}
        </textarea>
    </div>
</template>

<script>
    /* eslint-disable */
    import CodeMirror from 'codemirror'
    import 'codemirror/mode/javascript/javascript.js'
    import 'codemirror/lib/codemirror.css'
    import 'codemirror/theme/monokai.css'

    export default {
        name: 'landing-page',
        mounted: function () {
            CodeMirror.fromTextArea(document.getElementById('editor'), {
                lineNumbers: true,
                mode: 'text/javascript',
                theme: 'monokai'
            });
        }
    }
</script>

but javascript coloring scheme seems to not import

when i remove 2 first lines of imports and add to index.ejs this:

<script src="node_modules/codemirror/lib/codemirror.js"></script>
<script src="node_modules/codemirror/mode/javascript/javascript.js"></script>

it starts to working but of course it’s not my solution.

I thing its some problem in webpack confing.

Maybe sourcecode of codemirror/mode/javascript/javascript.js will help

bw

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
bwiercinskicommented, Oct 6, 2018

ok i had to add this to webpack renderer config

let whiteListedModules = ["vue", "codemirror", "vue-codemirror"];

issue can be closed

0reactions
bwiercinskicommented, Oct 1, 2018

@XanderLuciano

eventually I’m going to use component made by @surmon-china (witch has same problem with importing code coloring with this boilerplate webpack config), but I’m using pure Codemirror to be sure where the problem occurs. unfortunately i’m going to use features of codemirror, but i take some time to find similar in Ace. for now i spended sleepless nigths to know why this line of import doesn’t works

thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Help] Running into loader-related issue when trying to use ...
Hi, I'm just starting out with programming and trying to implement CodeMirror into a Javascript React project I'm working on.
Read more >
CodeMirror does not work with React/Webpack
Yes, it's an actual answer. You should just import some codemirror's css in your entrypoint file as it did in the example import...
Read more >
CodeMirror 6 / Visnu Pitiyanuvath
Yet another way to import and use CodeMirror 6 within Observable. Skypack makes this easy. See also CodeMirror 6 Playground and CodeMirror inside...
Read more >
uiw/react-codemirror
import React from 'react'; import CodeMirror from '@uiw/react-codemirror'; import { javascript } from '@codemirror/lang-javascript'; ...
Read more >
Code Mirror Issue
import { Component, ViewChild } from. '@angular/core';. import { CodemirrorComponent } from '@ctrl/. ngx-codemirror';. import 'codemirror/mode/javascript/.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found