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

本文翻译自:npm WARN package.json: No repository field

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. 我是Node.js和Express.js的新手。 Why do I have the above warnings? 为什么我有上述警告? Should I be worried? 我应该担心吗?


#1楼

参考:https://stackoom.com/question/18bh4/npm-WARN-package-json-没有存储库字段


#2楼

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 sooooooo many packages which still don't have the repository field in their package.json . 不过,不用担心,有仍然没有sooooooo许多包repository在自己的领域package.json The field is used for informational purposes. 该字段用于提供信息。

In the case you're a package author, put the repository in your package.json , like this: 如果您是包作者,请将repository放在package.json ,如下所示:

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

Read more about the repository field, and see the logged bug for further details. 阅读有关repository字段的更多repository ,并查看记录的错误以获取更多详细信息


Additionally, as originally reported by @dan_nl , you can set private key in your package.json . 此外, 正如@dan_nl最初报告的那样 ,您可以在package.json设置private
This will not only stop you from accidentally running npm publish in your app, but will also stop NPM from printing warnings regarding package.json problems. 这不仅会阻止您在应用程序中意外运行npm publish ,还会阻止NPM打印有关package.json问题的警告。

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

#3楼

If you are getting this from your own package.json , just add the repository field to it. 如果您从自己的package.json获取此信息,只需将repository字段添加到其中即可。 (use the link to your actual repository): (使用指向实际存储库的链接):

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

#4楼

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
}

#5楼

As dan_nl stated, you can add a private fake repository in package.json. 正如dan_nl所述,您可以在package.json中添加私有伪存储库。 You don't even need name and version for it: 你甚至不需要它的名称和版本:

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

Update: This feature is undocumented and might not work. 更新:此功能未记录,可能无法正常工作。 Choose the following option. 选择以下选项。

Better still: Set the private flag directly. 更好的是:直接设置private标志。 This way npm doesn't ask for a README file either: 这样,npm也不会要求README文件:

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

#6楼

Have you run npm init ? 你运行npm init吗? That command runs you through everything... 那个命令可以帮助你完成一切......

发布了0 篇原创文章 · 获赞 137 · 访问量 84万+

猜你喜欢

转载自blog.csdn.net/xfxf996/article/details/105438141