shikijs / shiki

A beautiful yet powerful syntax highlighter
http://shiki.style/
MIT License
9.91k stars 361 forks source link

Module not found: Error: Can't resolve 'shiki/wasm' in 'D:\test\node_modules\shiki\dist\chunks' #732

Closed xfstu closed 2 months ago

xfstu commented 2 months ago

Validations

Describe the bug

Execute the installation command: npm install -D shiki, and then use the example code:

<script>
import { codeToHtml } from 'shiki'
export default {
  data () {
    return {
    }
  },
  methods: {
    async test () {
      const code = 'const a = 1' // 输入代码片段
      const html = await codeToHtml(code, {
        lang: 'javascript',
        theme: 'vitesse-dark'
      })

      console.log(html) // 带有高亮显示的 HTML 字符串
    }
  },
  mounted () {

  }
}
</script>

cmd printing:

 ERROR  Failed to compile with 1 error                                                                          16:17:51

This dependency was not found:

* shiki/wasm in ./node_modules/shiki/dist/chunks/wasm-dynamic.mjs

To install it, you can run: npm install --save shiki/wasm

Browser print:

Failed to compile.

./node_modules/shiki/dist/chunks/wasm-dynamic.mjs
Module not found: Error: Can't resolve 'shiki/wasm' in 'D:\test\node_modules\shiki\dist\chunks'

Version: vue:2.7.14 npm:16.15.1

Reproduction

Reproducible

Contributes

antfu commented 2 months ago

We temporarily closed this due to the lack of enough information. We could not identify whether it was a bug or a userland misconfiguration with the given info. Please provide a minimal reproduction to reopen the issue. Thanks.

Why reproduction is required