Skip to content

node_modules/shiki/dist/types.d.mts:3:15 - error TS2307: Cannot find module '@shikijs/core/types' or its corresponding type declarations. #987

@hittten

Description

@hittten

Validations

Describe the bug

I've tried all the ways to configure Shiki listed in the documentation: https://shiki.matsu.io/guide/install#usage The front-end implementation using Angular works without problems. However, I'm currently implementing it with NodeJS, using Google Cloud Functions with a tsconfig configuration:

{
  "compilerOptions": {
    "module": "commonjs",
    "noImplicitReturns": true,
    "noUnusedLocals": true,
    "outDir": "lib",
    "sourceMap": true,
    "strict": true,
    "target": "es2017"
  },
  "compileOnSave": true,
  "include": [
    "src",
    "env.d.ts"
  ]
}

and there's no way to get the library working without receiving the error:

node_modules/shiki/dist/types.d.mts:3:15 - error TS2307: Cannot find module '@shikijs/core/types' or its corresponding type declarations.
  There are types at '/xxx/node_modules/@shikijs/core/dist/types.d.mts', but this result could not be resolved under your current 'moduleResolution' setting. Consider updating to 'node16', 'nodenext', or 'bundler'.

3 export * from '@shikijs/core/types';

I have tried the ESM implementation:

// ESM
import { createHighlighter } from 'shiki'

async function main() {
  const highlighter = await createHighlighter({
    themes: ['vitesse-dark'],
    langs: ['javascript'],
  })

  const code = highlighter.codeToHtml('const a = 1', {
    theme: 'vitesse-dark',
    lang: 'javascript',
  })
}

I have tried the CJS implementation:

// CJS
async function main() {
  const { createHighlighter } = await import('shiki')

  const highlighter = await createHighlighter({
    themes: ['vitesse-dark'],
    langs: ['javascript'],
  })

  const code = highlighter.codeToHtml('const a = 1', {
    theme: 'vitesse-dark',
    lang: 'javascript'
  })
}

Reproduction

https://github.com/hittten/testing-shikijs

Contributes

  • I am willing to submit a PR to fix this issue
  • I am willing to submit a PR with failing tests

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions