simple-code-editor icon indicating copy to clipboard operation
simple-code-editor copied to clipboard

Import error

Open Xeyos88 opened this issue 2 years ago • 2 comments

Hi, i have this error using this package: SyntaxError: The requested module '/node_modules/highlight.js/lib/index.js?v=a76deadf' does not provide an export named 'default' (at index.js?v=a76deadf:2:8) I use vite. I have currently removed lang = "ts" from my script (I saw it doesn't support it). I imported the component in a simple way:

import CodeEditor from 'simple-code-editor'

Xeyos88 avatar Aug 30 '22 14:08 Xeyos88

I am getting the same error (also using Vite with TypeScript)

martinszeltins avatar Sep 08 '22 14:09 martinszeltins

I've solved this by installing highlight.js:

npm install highlight.js and importing hljs

import hljs from "highlight.js";
import CodeEditor from 'simple-code-editor'

Also using Vite

cooljet84 avatar Sep 16 '22 12:09 cooljet84

@cooljet84 - can't get it working as per your suggestion. also using vite

nosehair avatar Jan 12 '23 02:01 nosehair

I've solved this by installing highlight.js:

npm install highlight.js and importing hljs

import hljs from "highlight.js";
import CodeEditor from 'simple-code-editor'

Also using Vite

Thank You! It is working perfectly.

nayan-7span avatar Mar 06 '23 13:03 nayan-7span

Instead of importing hightlight.js everywhere and potentially getting eslint's unused vars warning. We can add this to vite.config.js file:

// ...
optimizeDeps: {
    include: ['highlight.js']
}

Niush avatar Jun 26 '23 18:06 Niush