Skip to content

Commit 4ddaad8

Browse files
committed
add a note about shiki v2 installation
1 parent 4fcafc1 commit 4ddaad8

File tree

1 file changed

+19
-1
lines changed
  • app/web_development/tutorials/next-js-static-first-mdx-starterkit/code-highlighting-plugin

1 file changed

+19
-1
lines changed

app/web_development/tutorials/next-js-static-first-mdx-starterkit/code-highlighting-plugin/page.mdx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Code highlighting plugin - Next.js 15 Tutorial - Next.js 15 Tutorial
33
description: Code highlighting plugin - Next.js 15 static first MDX starterkit | Web development tutorials | www.chris.lu
44
keywords: ['highlighting', 'rehype', 'plugin', 'pretty', 'code', 'shiki']
55
published: 2024-12-31T23:00:00.000Z
6-
modified: 2025-01-20T23:00:00.000Z
6+
modified: 2025-01-23T23:00:00.000Z
77
permalink: https://chris.lu/web_development/tutorials/next-js-static-first-mdx-starterkit/code-highlighting-plugin
88
section: Web development
99
---
@@ -103,6 +103,24 @@ To install the **rehype pretty code** as well as the **shiki** package, we use t
103103
npm i rehype-pretty-code shiki --save-exact
104104
```
105105
106+
> [!WARN]
107+
> the latest shiki version is currently v2.x, but rehype-pretty-code expects a shiki v1 dependency, as there are no real [breaking changes](https://shiki.matsu.io/blog/v2#breaking-changes) in shiki v2 means it is safe to use shiki v2 with the [current (v0.14.0) rehype-pretty-code release](https://github.com/rehype-pretty/rehype-pretty-code/releases), but make sure to read over the [shiki v2 post](https://shiki.matsu.io/blog/v2#breaking-changes) as it contains interesting information about changes
108+
>
109+
> you will likely get an npm error like this:
110+
>
111+
> > npm error code ERESOLVE
112+
> > npm error ERESOLVE could not resolve
113+
>
114+
> either use the npm cli force flag, like so: `npm i rehype-pretty-code@latest shiki@latest --save-exact --force`
115+
>
116+
> Or add shiki to your overrides in your package.json:
117+
>
118+
> ```json title="package.json"
119+
> "overrides": {
120+
> "shiki": "2.1.0"
121+
> }
122+
> ```
123+
106124
Next, we edit our `next.config.mjs` file (in the root of our project) to add the plugin configuration like so:
107125
108126
```js title="next.config.mjs" showLineNumbers {2} {6} {15} /rehypePrettyCode/

0 commit comments

Comments
 (0)