node_modules报错,用patch-package给node_modules打补丁步骤,图文并茂超详细

报错:node_modules/@volar/vue-language-core中报错.
node_modules/@volar/vue-language-core/out/generators/template.js:553
localVars[varName] ??= 0;
^^^
SyntaxError: Unexpected token ‘??=’
node_modules报错,用patch-package给node_modules打补丁步骤,图文并茂超详细_第1张图片
答:需要给node_modules打补丁.
1、终端中执行命令:
npm i patch-package --save-dev
2、点击红框中报错的位置,将报错的位置更改;
node_modules报错,用patch-package给node_modules打补丁步骤,图文并茂超详细_第2张图片
更改后代码如下:
node_modules报错,用patch-package给node_modules打补丁步骤,图文并茂超详细_第3张图片

3、更改完终端执行命令:
npx patch-package @volar/vue-language-core
注意:@volar/vue-language-core是我报错的包名,你要换成你报错的包名,当终端显示如下证明更改成功
node_modules报错,用patch-package给node_modules打补丁步骤,图文并茂超详细_第4张图片
此时在node_modules下自动生成patches文件:
node_modules报错,用patch-package给node_modules打补丁步骤,图文并茂超详细_第5张图片
4、package.json中配置"postinstall": “patch-package”,当其他人安装完成后自动执行这个命令,其他人也可以用这个补丁.
node_modules报错,用patch-package给node_modules打补丁步骤,图文并茂超详细_第6张图片

你可能感兴趣的:(前端知识,vue)