Node.js 如何将git存储库用作依赖项并导入依赖项

Node.js 如何将git存储库用作依赖项并导入依赖项,node.js,git,github,npm,Node.js,Git,Github,Npm,最后一天,我在努力使用git存储库作为组件。 我尝试了很多方法,但当我键入npmi 以下是我尝试过的一些方法: , 我在git hub中创建了2个代表: =>应使用该组件 =>这是我的组件 每次我把它放在我的package.json(主项目repo)中,我都会遇到这样的错误: "dependencies": { "test-component": "IgorEstevao/test-component#master", # try 1 "test-component": "gi

最后一天,我在努力使用git存储库作为组件。 我尝试了很多方法,但当我键入
npmi

以下是我尝试过的一些方法:

,

我在git hub中创建了2个代表:

=>应使用该组件

=>这是我的组件

每次我把它放在我的package.json(主项目repo)中,我都会遇到这样的错误:

"dependencies": {
   "test-component": "IgorEstevao/test-component#master", # try 1
   "test-component": "git://github.com/IgorEstevao/test-component.git#0.0.1", # try 2
   "test-component": "git://github.com/IgorEstevao/test-component.git", # try 3...
}

npm错误!过早关闭

我如何在主项目中使用巧克力组件


请记住,在未来,我们将是私人的,因此,我认为我需要使用github api密钥来访问?

您应该将所有文件保存在项目根目录中,而不是将它们包装在
我的酷组件中
您应该将所有文件保存在项目根目录中,而不是将它们包装在
我的酷组件中
您似乎在你的JSON。JSON不允许尾随逗号。这很烦人

从依赖项对象中删除最后一个逗号

"dependencies": {
   "test-component": "IgorEstevao/test-component#master", # try 1
   "test-component": "git://github.com/IgorEstevao/test-component.git#0.0.1", # try 2
   "test-component": "git://github.com/IgorEstevao/test-component.git", # try 3...
}                                                                     ^
                                                                      |
                                                                      |
                                                                remove this
我对NPM不是很熟悉,但对同一个键使用三个不同的值不太可能有效


如果您希望将Github存储库用作NPM依赖项,以及

从1.1.65版开始,您可以将GitHub URL称为“foo”:“user/foo project”。就像git URL一样,可以包含commit-ish后缀

要依赖于
IgorEstevao/test组件的主分支
存储库

"dependencies": {
  "test-component": "IgorEstevao/test-component#master"
}

没有尾随逗号。

您的JSON中似乎有错误。JSON不允许尾随逗号。这很烦人

从依赖项对象中删除最后一个逗号

"dependencies": {
   "test-component": "IgorEstevao/test-component#master", # try 1
   "test-component": "git://github.com/IgorEstevao/test-component.git#0.0.1", # try 2
   "test-component": "git://github.com/IgorEstevao/test-component.git", # try 3...
}                                                                     ^
                                                                      |
                                                                      |
                                                                remove this
我对NPM不是很熟悉,但对同一个键使用三个不同的值不太可能有效


如果您希望将Github存储库用作NPM依赖项,以及

从1.1.65版开始,您可以将GitHub URL称为“foo”:“user/foo project”。就像git URL一样,可以包含commit-ish后缀

要依赖于
IgorEstevao/test组件的主分支
存储库

"dependencies": {
  "test-component": "IgorEstevao/test-component#master"
}
没有尾随逗号。

这是您实际的“依赖项”JSON吗?三个具有相同键和尾随逗号的条目?这是您实际的“依赖项”JSON吗?三个具有相同键和尾随逗号的条目?