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

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

Retrieving Node.js Module from GitHub - Error: ENOENT, open package/package.json'

node.jsnpm

提问by latvian

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 安装模块?谢谢你

回答by Peter Lyons

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

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

回答by matsko

You may be using a .zipfile. 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

回答by Caleb Syring

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 startfrom one directory above. Hope this helps.

以防万一您没有注意到已接受答案下方的评论,您需要确保您在应用程序文件夹中才能运行npm start. 不小心npm start从上面的一个目录运行似乎是一个常见的错误。希望这可以帮助。