今天准备将园子的 vscode 插件所依赖的 npm 全部升级至最新版
注:这个插件是开源的,github 仓库地址:https://github.com/cnblogs/vscode-cnb
使用下面的命令完成升级
ncu --upgrade
npm i --legacy-peer-deps
执行下面的命令进行 build
npm version 1.0.0-beta.$(date +%s) -git-tag-version false && \
npm run package && \
npx @vscode/vsce package
build 过程中报错
> node ./build.mjs
X [ERROR] Could not resolve "highlight.js"
node_modules/@cnblogs/markdown-it-presets/dist/es2015/presets/index.mjs:2:17:
2 │ import hljs from 'highlight.js';
╵ ~~~~~~~~~~~~~~
You can mark the path "highlight.js" as external to exclude it from the bundle, which will remove
this error and leave the unresolved path in the bundle.
Error: Build failed with 2 errors:
node_modules/@cnblogs/markdown-it-presets/dist/es2015/presets/index.mjs:2:17: ERROR: Could not resolve "highlight.js"
C:\dev\github\vscode-cnb\node_modules\@sprout2000\esbuild-copy-plugin\dist\index.js:40:61: ERROR: [plugin: esbuild-copy-plugin] ENOENT: no such file or directory, lstat 'C:\dev\github\vscode-cnb\node_modules\@mapbox\node-pre-gyp'
at failureErrorWithLog (C:\dev\github\vscode-cnb\node_modules\esbuild\lib\main.js:1467:15)
at C:\dev\github\vscode-cnb\node_modules\esbuild\lib\main.js:926:25
at C:\dev\github\vscode-cnb\node_modules\esbuild\lib\main.js:1345:9
at process.processTicksAndRejections (node:internal/process/task_queues:105:5) {
errors: [Getter/Setter],
warnings: [Getter/Setter]
}
后来发现解决方法很简单,专门安装一下 highlight.js 包即可
npm i highlight.js --legacy-peer-deps