node.js npm WARN package.json:没有存储库字段

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16827858/
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 14:39:13  来源:igfitidea点击:

npm WARN package.json: No repository field

node.jsexpressnpm

提问by JR Galia

I installed Express.js with the following command:

我使用以下命令安装了 Express.js:

sudo npm install -g express

I get the following warnings:

我收到以下警告:

npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No readme data.
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No repository field.

I'm new to Node.js and Express.js. Why do I have the above warnings? Should I be worried?

我是 Node.js 和 Express.js 的新手。为什么我有上述警告?我应该担心吗?

回答by gustavohenke

It's just a check as of NPM v1.2.20, they report this as a warning.

这只是 NPM v1.2.20 的检查,他们将此报告为警告。

However, don't worry, there are sooooooomany packages which still don't have the repositoryfield in their package.json. The field is used for informational purposes.

不过,不用担心,有sooooooo仍然没有很多包repository在自己的领域package.json。该字段用于提供信息。

In the case you're a package author, put the repositoryin your package.json, like this:

如果您是包作者,请将 放入repository您的 中package.json,如下所示:

"repository": {
  "type": "git",
  "url": "git://github.com/username/repository.git"
}

Read more about the repositoryfield, and see the logged bugfor further details.

阅读有关该repository领域的更多信息,并查看记录的错误以获取更多详细信息。



Additionally,as originally reported by @dan_nl, you can set privatekey in your package.json.
This will not only stop you from accidentally running npm publishin your app, but will also stop NPM from printing warnings regarding package.jsonproblems.

此外,正如@dan_nl 最初报道的那样,您可以privatepackage.json.
这不仅会阻止您npm publish在应用程序中意外运行,还会阻止 NPM 打印有关package.json问题的警告。

{
  "name": "my-super-amazing-app",
  "version": "1.0.0",
  "private": true
}

回答by dan_nl

you can also mark the application as private if you don't plan to put it in an actual repository.

如果您不打算将其放入实际存储库中,您也可以将应用程序标记为私有。

{
  "name": "my-application",
  "version": "0.0.1",
  "private": true
}

回答by wortwart

As dan_nl stated, you can add a private fake repository in package.json. You don't even need name and version for it:

正如 dan_nl 所说,您可以在 package.json 中添加一个私有的假存储库。您甚至不需要名称和版本:

{
  ...,
  "repository": {
    "private": true
  }
}

Update: This feature is undocumented and might not work. Choose the following option.

更新:此功能未记录,可能无法使用。选择以下选项。

Better still: Set the privateflag directly. This way npm doesn't ask for a README file either:

更好的是:private直接设置标志。这样 npm 也不会要求 README 文件:

{
  "name": ...,
  "description": ...,
  "version": ...,
  "private": true
}

回答by Brendan Nee

If you are getting this from your own package.json, just add the repositoryfield to it. (use the link to your actual repository):

如果你是从你自己得到这个package.json,只是加repository场到它。(使用指向您实际存储库的链接):

"repository" : { 
   "type" : "git",
   "url" : "https://github.com/npm/npm.git"
 }

回答by achoukah

Have you run npm init? That command runs you through everything...

你跑了npm init吗?该命令将引导您完成所有操作...

回答by Shashwat Gupta

In Simple word-package.json of your project has not property of repository you must have to add it,

您的项目的Simple word-package.json 中没有存储库的属性,您必须添加它,

and you have to add repository in your package.json like below

你必须在你的 package.json 中添加存储库,如下所示

enter image description here

在此处输入图片说明

and Let me explain according to your scenario

让我根据你的情况来解释

you must have to add repository field something like below

您必须添加如下所示的存储库字段

  "repository" : {     
     "type" : "git",
      "url" : "http://github.com/npm/express.git" 
   }

回答by Alex

To avoid warnings like:

为避免出现以下警告:

npm WARN [email protected] No repository field.

You must define repository in your project package.json. In the case when you are developing with no publishing to the repository you can set "private": truein package.json

您必须在项目 package.json 中定义存储库。在没有发布到存储库的情况下进行开发时,您可以"private": true在 package.json 中设置

Example:

例子:

{
  "name": "test.loc",
  "version": "1.0.0",
  "private": true,
  ...
  "license": "ISC"
}

NPM documentation about this: https://docs.npmjs.com/files/package.json

关于此的 NPM 文档:https: //docs.npmjs.com/files/package.json

回答by Rubin bhandari

If you don't want to specify a repository you can add the following lines to the package.jsonfile:

如果您不想指定存储库,可以将以下行添加到package.json文件中:

"description":"",
"version":"0.0.1",
"private":true,

That worked for me.
By adding private, you don't need to link to a repo.

那对我有用。
通过添加private,您无需链接到存储库。

回答by Ian Croasdell

this will help all of you to find your own correct details use

这将帮助你们所有人找到自己正确的详细信息使用

npm ls dist-tag

this will then show the correct info so you don't guess the version file location etc

这将显示正确的信息,因此您不会猜测版本文件位置等

enjoy :)

请享用 :)

回答by Jsalim

Yes, probably you can re/create one by including -fat the end of your command

是的,也许您可​​以通过-f在命令末尾包含来重新/创建一个