node.js 运行 npm install 时 package.json 未安装依赖项

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

package.json isn't installing dependencies when running npm install

node.jsnpm

提问by marcc

I've created a package.jsonfile for my private app. In it, I have my dependencies listed, as expected. Some of those dependencies have dependencies of their own. When running npm installon my app, it's not installing the dependencies of my dependencies. Is there something wrong with my package.json file which is preventing this? ("winston" is one of my dependencies which isn't properly installing)

package.json为我的私人应用程序创建了一个文件。在其中,我按预期列出了我的依赖项。其中一些依赖项有自己的依赖项。npm install在我的应用程序上运行时,它没有安装我的依赖项的依赖项。我的 package.json 文件有什么问题阻止了这个吗?(“winston”是我未正确安装的依赖项之一)

{  
  "name": "my app",  
  "version": "0.0.1",  
  "dependencies" : {  
    "connect" : "1.8.5",  
    "express" : "2.5.8",  
    "socket.io" : "0.8.7",  
    "winston" : "0.5.9"
  },  
  "engine": {  
    "node": ">=0.6"  
  }  
}

Reponse to comments: NPM installs the top level deps, fine, no errors, it looks like it works. It just never downloads the deps of the deps. Will try the -d option.

回复评论:npm 安装了顶级 deps,很好​​,没有错误,看起来可以。它只是从不下载 deps 的 deps。将尝试 -d 选项。

回答by Samuel

Spaces are not allowed in the nameoption for package.json files.

namepackage.json 文件的选项中不允许有空格。

The name ends up being part of a URL, an argument on the command line, and a folder name. Therefore, the name can't contain any non-URL-safe characters.

该名称最终成为 URL 的一部分、命令行上的参数和文件夹名称。因此,名称不能包含任何非 URL 安全字符。

https://docs.npmjs.com/files/package.json#name

https://docs.npmjs.com/files/package.json#name

回答by magikid

I had the same issue and with some googling, it seems that this is a problem in node.js: https://github.com/isaacs/npm/issues/1341

我有同样的问题,并通过一些谷歌搜索,这似乎是 node.js 中的一个问题:https: //github.com/isaacs/npm/issues/1341

回答by ming_codes

I noticed the winstonline is ended with ,

我注意到该winston行以,

This is not a valid JSON.

这不是有效的 JSON。