有没有办法强制 npm 生成 package-lock.json? [英] Is there a way to force npm to generate package-lock.json?

查看:204
本文介绍了有没有办法强制 npm 生成 package-lock.json?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不小心删除了它,并且从那以后对 package.json 做了很多更改.npm installnpm update 不再生成 package-lock.json.我尝试清除 npm 缓存和 nvm 缓存,但似乎没有任何效果.我在多个版本的 Node.js 上尝试过(6.10.3 Node.js - 3.10.10 npm 是我希望它使用的),但它在任何版本上都不起作用.

I deleted it by accident and have made many changes to package.json since. An npm install or npm update do not generate package-lock.json anymore. I tried clearing my npm cache and my nvm cache, but nothing seems to be working. I tried it on several versions of Node.js (6.10.3 Node.js - 3.10.10 npm is what I would like it to work on), and it doesn't work on any.

有没有办法强制 npm 生成 package-lock.json 文件?

Is there a way to force npm to generate the package-lock.json file?

推荐答案

在 npm 6.x 和 7.x 中你可以使用

In npm 6.x and 7.x you can use

npm i --package-lock-only

根据https://docs.npmjs.com/cli/install.html

--package-lock-only 参数只会更新 package-lock.json,而不是检查 node_modules 和下载依赖项.

The --package-lock-only argument will only update the package-lock.json, instead of checking node_modules and downloading dependencies.

这篇关于有没有办法强制 npm 生成 package-lock.json?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆