为什么 npm 安装会降低依赖版本
Why npm installation decrease dependencies versions
我在使用 npm
安装包时遇到问题,它正在减少破坏我的应用程序和单元测试的依赖版本,例如我的 package.lock
文件安装后看起来像:
请告诉我如何在不降低依赖项版本的情况下安装包?
您可以尝试使用 npm ci
:
In short, the main differences between using npm install and npm ci are:
- The project must have an existing package-lock.json or npm-shrinkwrap.json.
- If dependencies in the package lock do not match those in package.json, npm ci will exit with an error, instead of updating the package lock.
- npm ci can only install entire projects at a time: individual dependencies cannot be added with this command.
- If a node_modules is already present, it will be automatically removed before npm ci begins its install.
- It will never write to package.json or any of the package-locks: installs are essentially frozen.
我在使用 npm
安装包时遇到问题,它正在减少破坏我的应用程序和单元测试的依赖版本,例如我的 package.lock
文件安装后看起来像:
您可以尝试使用 npm ci
:
In short, the main differences between using npm install and npm ci are:
- The project must have an existing package-lock.json or npm-shrinkwrap.json.
- If dependencies in the package lock do not match those in package.json, npm ci will exit with an error, instead of updating the package lock.
- npm ci can only install entire projects at a time: individual dependencies cannot be added with this command.
- If a node_modules is already present, it will be automatically removed before npm ci begins its install.
- It will never write to package.json or any of the package-locks: installs are essentially frozen.