简体   繁体   English

NPM没有安装包

[英]NPM not installing packages

I have a project with dependencies in package.json. 我在package.json中有一个带依赖项的项目。 When I install with npm install , I get packages installed in ~/.npm but not in the current folder's node_modules . 当我使用npm install ,我得到的软件包安装在~/.npm但不在当前文件夹的node_modules

NPM is creating node_modules , but not installing packages there. NPM正在创建node_modules ,但不在那里安装包。 There's a .staging folder within node_modules , which contains all of the packages for the projects, but they're not being moved out after retrieval. 有一个.staging内的文件夹node_modules ,它包含了所有的包项目,但检索后,他们没有被搬走了。

Using Node v6.9.1 / npm v3.10.8. 使用Node v6.9.1 / npm v3.10.8。

There aren't any other projects/node_modules installed in directories higher than the current one, though there is a package.json in the parent directory as well. 虽然在父目录中也有一个package.json,但是在高于当前目录的目录中没有安装任何其他项目/ node_modules。 No node_modules directory gets created in the parent directory, however. 但是,不会在父目录中创建node_modules目录。

Strangely enough, when I manually install a package like npm install @angular/core it installs without problem. 奇怪的是,当我手动安装像npm install @angular/core这样的软件包时,它的安装没有问题。

This is on Ubuntu 16.04. 这是在Ubuntu 16.04上。

package.json: 的package.json:

{ 
  "name": "", 
  "version": "0.5.0", 
  "description": "website (Angular2/NodeJS)", 
  "main": "main.js", 
  "scripts": { 
    "test": "echo \"Error: no test specified\" && exit 1" 
  }, 
  "author": "John Halbert <https://halbert.tech> (john@halbert.tech)", 
  "license": "SEE LICENSE IN LICENSE.md", 
  "dependencies": { 
    "@angular/common": "^2.1.1", 
    "@angular/compiler": "^2.1.1", 
    "@angular/core": "^2.1.1", 
    "@angular/forms": "^2.1.1", 
    "@angular/http": "^2.1.1", 
    "@angular/platform-browser": "^2.1.1", 
    "@angular/platform-browser-dynamic": "^2.1.1", 
    "@angular/router": "^3.1.1", 
    "core-js": "^2.4.1", 
    "reflect-metadata": "^0.1.8", 
    "systemjs": "^0.19.39", 
    "zone.js": "^0.6.26" 
  },
  "devDependencies": { 
    "concurrently": "^3.1.0", 
    "typings": "^1.4.0" 
  } 
}

Try to run 试着跑

echo "" > $(npm config get userconfig)
npm config edit

To see if you have change de node modules default folder, if so, you can reset the configurations by doing 要查看是否更改了节点模块的默认文件夹,如果是,您可以通过执行重置配置

echo "" > $(npm config get globalconfig)
npm config --global edit

After doing more research it looks like this is a memory issue with my server. 在做了更多的研究后,看起来这是我的服务器的内存问题。 Running on a low-end VPS with 128Mb RAM. 在具有128Mb RAM的低端VPS上运行。

There are a few suggestions on how to deal with this. 关于如何处理这个问题,有一些建议。 I found others suggesting npm config set jobs 1 as a way to limit memory usage, but this hasn't worked for me. 我发现其他人建议将npm config set jobs 1作为限制内存使用的方法,但这对我没有用。 Others suggest adding (more) swap, which is disallowed by my hosting provider. 其他人建议添加(更多)交换,这是我的托管服务提供商不允许的。

The npm process is actually being killed so it appears this is likely the culprit. npm进程实际上正在被杀死所以看起来这可能是罪魁祸首。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM