简体   繁体   English

Npm 安装后不保存到 package.json

[英]Npm not saving to package.json after installation

Each time I run npm i it does not save to package.json after successful installation rather it will save to package-lock.json file.每次我运行 npm i 时,它都不会保存到 package.json 安装成功后,而是保存到 package-lock.Z6466DEEC7F6ECDF245 文件。 Please I need help.请我需要帮助。 I have tried using npm cache clean --force but always get this error npm WARN using --force Recommended protections disabled.我曾尝试使用 npm 缓存清理 --force 但总是收到此错误 npm WARN using --force 建议保护已禁用。

Thanks in advance.提前致谢。

If you are asking npm install , it is executing to install all packages depends on your package.json and package-log.json.如果您要问npm install ,它正在执行安装所有软件包取决于您的 package.json 和 package-log.package.json 和 package-log.ZEFE90A8E604A7F6ECDF45

If you have both package.json and package-lock.json, it will only check and install/update the packages and related version mentioned the 2 files.如果您同时拥有 package.json 和 package-lock.json,它只会检查和安装/更新提到 2 个文件的包和相关版本。 It won't modify the 2 files because package-lock.json file exists.它不会修改这两个文件,因为 package-lock.json 文件存在。

It package-lock.json file not exists, then it will install/update latest version from package.json, update the version installed to package.json, and create package-lock.json. It package-lock.json file not exists, then it will install/update latest version from package.json, update the version installed to package.json, and create package-lock.json.

If you are asking npm install [a package] , then after installed it should update package.json and package-lock.json to add the new package in the file. If you are asking npm install [a package] , then after installed it should update package.json and package-lock.json to add the new package in the file.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM