npm 不常见命令及参数归集
npm 不常用命令及参数记录
npm audit fix --force
强制对项目的依赖包进行升级,即便是超出了package.json指定的版本,可能修复未知的安全漏洞,也会带来版本不兼容的问题。当时nestjs 项目eslint有问题,报错 --“Failed to load plugin '@typescript-eslint' declared in '.eslintrc': Class extends value undefined is not a constructor or null”-- https://stackoverflow.com/questions/71067936/failed-to-load-plugin-typescript-eslint-declared-in-eslintrc-class-extend?newreg=c3cb653aaab342b9953c45b51b227774 解决了问题。这个命令能运行的前提是需要有lock文件。
npm install --legacy-peer-deps
忽视对等依赖的安装,不终止任务,直接安装指定的版本;比如package.json中react版本为18,某个包的对等依赖react17,可以加上这个命令忽略