从GitHub检索Node.js模块 - 错误:ENOENT,打开package / package.json'

时间:2022-04-26 15:27:43

To my understanding, the 'npm' knows about git, so i can use it to retrieve Node.js modules from github. So, I have created Node.js module and hosted it at github. When I try to install it in my Node.js project as following:

根据我的理解,'npm'知道git,所以我可以用它从github中检索Node.js模块。所以,我创建了Node.js模块并在github上托管它。当我尝试在我的Node.js项目中安装它时如下:

npm install git://github.com/git-user/repo.git

then i am getting following error:

然后我得到以下错误:

 Error: ENOENT, open '/Users/kapa/tmp/npm-12237/1371351143597-0.9469406655989587/package/package.json'
...
code ENOENT
npm ERR! errno 34

What am i doing wrong and how to install module from github? Thank You

我做错了什么以及如何从github安装模块?谢谢

3 个解决方案

#1


28  

Does your repository contain a proper package.json file? That is required to have your repository handled as an npm module.

您的存储库是否包含正确的package.json文件?这需要将您的存储库作为npm模块处理。

#2


1  

You may be using a .zip file. NPM doesn't support it and it may throw an error. Here is what you can use: https://npmjs.org/doc/install.html#DESCRIPTION

您可能正在使用.zip文件。 NPM不支持它,它可能会引发错误。您可以使用以下内容:https://npmjs.org/doc/install.html#DESCRIPTION

#3


0  

For those who already have a package.json file:

对于那些已经拥有package.json文件的人:

Just in case you didn't notice the comments below the accepted answer, you need to make sure you are inside your app folder to be able to run npm start. It seems to be a common mistake to accidentally run npm start from one directory above. Hope this helps.

如果你没有注意到接受答案下方的评论,你需要确保你在你的app文件夹中才能运行npm start。从上面的一个目录中意外运行npm start似乎是一个常见的错误。希望这可以帮助。

#1


28  

Does your repository contain a proper package.json file? That is required to have your repository handled as an npm module.

您的存储库是否包含正确的package.json文件?这需要将您的存储库作为npm模块处理。

#2


1  

You may be using a .zip file. NPM doesn't support it and it may throw an error. Here is what you can use: https://npmjs.org/doc/install.html#DESCRIPTION

您可能正在使用.zip文件。 NPM不支持它,它可能会引发错误。您可以使用以下内容:https://npmjs.org/doc/install.html#DESCRIPTION

#3


0  

For those who already have a package.json file:

对于那些已经拥有package.json文件的人:

Just in case you didn't notice the comments below the accepted answer, you need to make sure you are inside your app folder to be able to run npm start. It seems to be a common mistake to accidentally run npm start from one directory above. Hope this helps.

如果你没有注意到接受答案下方的评论,你需要确保你在你的app文件夹中才能运行npm start。从上面的一个目录中意外运行npm start似乎是一个常见的错误。希望这可以帮助。