justcaliturner / simple-code-editor

Simple code editor for Vue.js
https://simple-code-editor.vicuxd.com
150 stars 27 forks source link

Import error #20

Closed Xeyos88 closed 1 year ago

Xeyos88 commented 2 years ago

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'
martinszeltins commented 2 years ago

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

cooljet84 commented 2 years ago

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

nosehair commented 1 year ago

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

nayan-7span commented 1 year ago

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.

Niush commented 1 year ago

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']
}