node.js npm 通知创建了一个锁文件作为 package-lock.json。你应该提交这个文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/44343997/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 18:15:36  来源:igfitidea点击:

npm notice created a lockfile as package-lock.json. You should commit this file

jsonnode.jsgitexpress

提问by Venkateshreddy Pala

I have been trying to load the skeleton of express with npm install express. It outputs the following line:

我一直在尝试使用npm install express. 它输出以下行:

npm notice created a lockfile as package-lock.json. You should commit this file.

npm 通知创建了一个锁文件作为 package-lock.json。你应该提交这个文件。

What should I do in order to load the template ejs and css engine automatically?

我应该怎么做才能自动加载模板 ejs 和 css 引擎?

回答by zoecarver

Yes. You should add this file to your version control system, i.e. You should commit it.

是的。您应该将此文件添加到您的版本控制系统,即您应该提交它。

This file is intended to be committed into source repositories

此文件旨在提交到源存储库中

You can read more about what it is/what it does here:

您可以在此处阅读有关它是什么/它做什么的更多信息:

package-lock.json is automatically generated for any operations where npm modifies either the node_modules tree, or package.json. It describes the exact tree that was generated, such that subsequent installs are able to generate identical trees, regardless of intermediate dependency updates.

package-lock.json 会为任何 npm 修改 node_modules 树或 package.json 的操作自动生成。它描述了生成的确切树,以便后续安装能够生成相同的树,而不管中间依赖项更新如何。

回答by Rahul Mankar

You can update the existing package-lock.json file instead of creating a new one. Just change the version number to a different one.

您可以更新现有的 package-lock.json 文件而不是创建一个新文件。只需将版本号更改为不同的版本号即可。

{ "name": "theme","version": "1.0.1", "description": "theme description"}

回答by barbara

Yes it is wise to use a version control system for your project. Anyway, focusing on your installation warning issue you can try to launch npm install command starting from your root project folder instead of outside of it, so the installation steps will only update the existing package-lock.json file instead of creating a new one. Hope this helps.

是的,为您的项目使用版本控制系统是明智的。无论如何,关注您的安装警告问题,您可以尝试从根项目文件夹而不是外部启动 npm install 命令,因此安装步骤只会更新现有的 package-lock.json 文件,而不是创建一个新文件。希望这可以帮助。

回答by Donald L Wilson

It should also be noted that one key detail about package-lock.json is that it cannot be published, and it will be ignored if found in any place other than the top level package. It shares a format with npm-shrinkwrap.json(5), which is essentially the same file, but allows publication. This is not recommended unless deploying a CLI tool or otherwise using the publication process for producing production packages.

还需要注意的是,package-lock.json 的一个关键细节是不能发布,如果在顶级包以外的任何地方发现它都会被忽略。它与 npm-shrinkwrap.json(5) 共享一种格式,它本质上是相同的文件,但允许发布。除非部署 CLI 工具或以其他方式使用发布过程来生成生产包,否则不建议这样做。

If both package-lock.json and npm-shrinkwrap.json are present in the root of a package, package-lock.json will be completely ignored.

如果 package-lock.json 和 npm-shrinkwrap.json 都存在于包的根目录中, package-lock.json 将被完全忽略。

回答by antorpramanik

Check for package-lock.jsonfile at C:\Windows\system32.

检查package-lock.json文件C:\Windows\system32

If it doesn't exist, run cmdas admin and execute the following commands:

如果它不存在,请cmd以管理员身份运行并执行以下命令:

Set EXPO_DEBUG=true
npm config set package-lock false
npm install

回答by Neha Sharma

Yes you should, As it locks the version of each and every package which you are using in your app and when you run npm installit install the exact same version in your node_modules folder. This is important becasue let say you are using bootstrap 3 in your application and if there is no package-lock.json file in your project then npm installwill install bootstrap 4 which is the latest and you whole app ui will break due to version mismatch.

是的,您应该这样做,因为它会锁定您在应用程序中使用的每个包的版本,并且当您运行npm install它时,会在您的 node_modules 文件夹中安装完全相同的版本。这很重要,因为假设您在应用程序中使用 bootstrap 3,如果您的项目中没有 package-lock.json 文件,那么npm install将安装最新的 bootstrap 4,并且您的整个应用程序 ui 将由于版本不匹配而中断。

回答by Abhishek

came out of this issue by changing the version in package.json file and also changing the name of the package and finally deleted the package-lock.json file

通过更改 package.json 文件中的版本以及更改包的名称解决了这个问题,最后删除了 package-lock.json 文件