npm5 相当于 yarn 的 --pure-lockfile 标志?

npm5 equivalent to yarn's --pure-lockfile flag?

我正在寻找 yarn --pure-lockfile flag.

的等效项

在 CI 中安装依赖项时,当您希望它读取您的锁定文件但不修改它时,此标志很有用。

npm v5 有等效项吗?

npm 5.7 引入了 npm ci 子命令:

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.

这就是我在 dockerfile

中所做的
RUN npm install --pure-lockfile

它应该可以完美运行。