全局安装@vue/cli遇4个漏洞,npm audit fix --force无法解决求助
Vue CLI全局安装漏洞修复报错问题
我曾卸载Node.js尝试解决问题但未成功,在空文件夹中创建Vue.js应用时,执行npm install -g @vue/cli提示存在4个漏洞(2个中等、2个高危),执行npm audit fix --force时出现报错,具体日志如下:
执行npm install -g @vue/cli的日志
npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated npm WARN deprecated subscriptions-transport-ws@0.11.0: The `subscriptions-transport-ws` package is no longer maintained. We recommend you use `graphql-ws` instead. For help migrating Apollo software to `graphql-ws`, see https://www.apollographql.com/docs/apollo-server/data/subscriptions/#switching-from-subscriptions-transport-ws For general help using `graphql-ws`, see https://github.com/enisdenjo/graphql-ws/blob/master/README.md changed 847 packages, and audited 848 packages in 26s 64 packages are looking for funding run `npm fund` for details 4 vulnerabilities (2 moderate, 2 high) To address all issues (including breaking changes), run: npm audit fix --force Run `npm audit` for details.
执行npm audit fix --force的日志
npm WARN using --force Recommended protections disabled. npm ERR! code ENOLOCK npm ERR! audit This command requires an existing lockfile. npm ERR! audit Try creating one first with: npm i --package-lock-only npm ERR! audit Original error: loadVirtual requires existing shrinkwrap file npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\freir\AppData\Local\npm-cache\_logs\2022-11-08T13_17_58_614Z-debug-0.log
当前node -v和npm -v版本均正常,急需解决方法。
解决步骤:
- 全局安装的包默认没有生成lock文件,先为全局包创建lock文件:
npm i --package-lock-only -g - 生成lock文件后,再执行全局漏洞修复:
npm audit fix --force -g - 若上述步骤无效,尝试升级npm到最新版本:
npm install -g npm - 也可直接安装最新版Vue CLI,新版本通常会修复依赖的已知漏洞:
npm install -g @vue/cli@latest
内容的提问来源于stack exchange,提问作者matt_bolo
相关产品推荐
相关产品推荐

