NPM 未安装软件包

问题描述 投票:0回答:2

我有一个项目,在 package.json 中有依赖项。当我使用

npm install
安装时,我将软件包安装在
~/.npm
中,但不在当前文件夹的
node_modules
中。

NPM 正在创建

node_modules
,但不在那里安装软件包。
.staging
中有一个
node_modules
文件夹,其中包含项目的所有包,但检索后它们不会被移出。

使用节点 v6.9.1 / npm v3.10.8。

虽然父目录中也有一个 package.json ,但没有任何其他项目/node_modules安装在比当前目录更高的目录中。但是,不会在父目录中创建

node_modules
目录。

奇怪的是,当我手动安装像

npm install @angular/core
这样的软件包时,它安装没有问题。

这是在 Ubuntu 16.04 上。

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> ([email protected])", 
  "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" 
  } 
}
node.js npm npm-install package.json
2个回答
0
投票

尝试跑步

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

查看您是否更改了节点模块的默认文件夹,如果是,您可以通过以下方式重置配置

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

0
投票

经过更多研究后,这似乎是我的服务器的内存问题。在具有 128Mb RAM 的低端 VPS 上运行。

有一些关于如何处理这个问题的建议。我发现其他人建议

npm config set jobs 1
作为限制内存使用的方法,但这对我不起作用。其他人建议添加(更多)交换,这是我的托管提供商不允许的。

npm 进程实际上被杀死了,所以看起来这可能是罪魁祸首。

© www.soinside.com 2019 - 2024. All rights reserved.