具体错误
$ sudo 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! /home/tsit/.npm/_logs/2022-12-13T07_12_26_971Z-debug-0.log
初始化
$ sudo npm init --yes Wrote to /home/tsit/package.json: { "name": "tsit", "version": "1.0.0", "description": "", "main": "index.js", "directories": { "test": "test" }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC" }
创建package-lock-only
$ sudo npm i --package-lock-only up to date, audited 1 package in 114ms found 0 vulnerabilities
自动修复
$ sudo npm audit fix --force npm WARN using --force Recommended protections disabled. up to date, audited 1 package in 98ms found 0 vulnerabilities
验证
执行相应命令。比如我安装的是syberh:
$ syberh -version 2.2.4