node.js 无法 npm 安装我的包

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

Unable to npm install my package

node.jsnpm

提问by toomasr

I've been trying to install a package that I have defined the package.jsonfor. The package.jsonfile is very simple.

我一直在尝试安装一个我为其定义了package.json 的包。该的package.json文件是非常简单的。

{
  "name": "project",
  "version": "0.0.1",
  "devDependencies": {
    "karma-jasmine": "0.2.2"
  }
}

Now when I issue a

现在当我发出

npm install .

I get the following error.

我收到以下错误。

npm WARN package.json [email protected] No repository field.
npm ERR! addLocal Could not install /Users/username/projects/project
npm ERR! Darwin 14.0.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "."
npm ERR! node v0.10.32
npm ERR! npm  v2.1.5
npm ERR! code EISDIR
npm ERR! errno 28

npm ERR! EISDIR, read
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <http://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/username/projects/project/npm-debug.log

Unable to understand what am I doing wrong.

无法理解我做错了什么。

回答by toomasr

After spending a lot of time on this I finally figured out the cause. I didn't have a package.jsonfile but I had it misspeltas packages.json file.

在花了很多时间之后,我终于找到了原因。我没有package.json文件,但我把它拼错为 packages.json 文件。

NPM wasn't able to pick up the file from the current directory and then it tried my home directory and then showed the unhelpful error. I hope this will help somebody save some time.

NPM 无法从当前目录中提取文件,然后它尝试了我的主目录,然后显示了无用的错误。我希望这会帮助某人节省一些时间。

回答by Scott Stensland

Top Tip - once you have created your new project's github repository and cloned it locally, issue the command :

重要提示 - 创建新项目的 github 存储库并将其克隆到本地后,发出命令:

npm init    

which will prompt you for particulars and auto synthesize a file

这将提示您输入详细信息并自动合成文件

package.json

for you

为你

UPDATE : I see its been fixed ... my current version has a much better error message :

更新:我看到它已修复......我当前的版本有一个更好的错误消息:

npm install
npm WARN ENOENT ENOENT: no such file or directory, open '/home/scott/aaa/package.json'


node --version
v5.4.1

npm --version
3.3.12