Keystonejs - 使用npm安装依赖项失败

问题描述:

我已经浪费了四个小时,试图在生产环境中安装我的'keystonejs`项目的所有依赖项。Keystonejs - 使用npm安装依赖项失败

npm只是挂起,然后我得到这个消息:

<--- Last few GCs ---> 

    859221 ms: Scavenge 116.4 (156.1) -> 115.5 (156.1) MB, 164.5/0 ms (+ 1116.0 ms in 14 steps since last GC) [allocation failure]. 
1003590 ms: Scavenge 116.5 (156.1) -> 115.6 (156.1) MB, 15.8/15 ms (+ 1588.7 ms in 14 steps since last GC) [allocation failure]. 
1003797 ms: Scavenge 116.5 (156.1) -> 115.6 (156.1) MB, 0.5/0 ms (+ 1.0 ms in 14 steps since last GC) [allocation failure]. 


<--- JS stacktrace ---> 

==== JS stack trace ========================================= 

Security context: 0x3fb4b37e3ac1 <JS Object> 
    1: baseClone(aka baseClone) [/usr/local/lib/node_modules/npm/node_modules/lodash.clonedeep/index.js:~253] [pc=0xbd65c4932f9] (this=0x3fb4b3704189 <undefined>,value=0x35b70929ee81 <an Object with map 0x16ee5e917979>,isDeep=0x3fb4b3704231 <true>,customizer=0x3fb4b3704189 <undefined>,key=0,object=0x35b70928f3d1 <JS Array[8]>,stack=0x1c3082095b39 <a Stack with map 0x3ad6ac90daa9>) 
    2: /* ano... 

FATAL ERROR: Committing semi space failed. Allocation failed - process out of memory 

这是我的`package.json``

{ 
    "name": "mysite", 
    "version": "0.0.0", 
    "private": true, 
    "dependencies": { 
    "keystone": "^0.3.16", 
    "async": "^1.5.0", 
    "underscore": "^1.8.3", 
    "node-sass": "^3.3.2", 
    "node-sass-middleware": "^0.9.7", 
    "dotenv": "^1.1.0" 
    }, 
    "devDependencies": { 
    "grunt": "^0.4.4", 
    "grunt-express-server": "^0.4.17", 
    "grunt-contrib-watch": "^0.6.1", 
    "grunt-contrib-jshint": "^0.7.1", 
    "jshint-stylish": "^2.0.1", 
    "load-grunt-tasks": "^0.4.0", 
    "load-grunt-configs": "^0.4.1", 
    "grunt-node-inspector": "^0.4.1", 
    "time-grunt": "^0.3.1", 
    "grunt-concurrent": "^0.5.0", 
    "grunt-nodemon": "^0.2.1", 
    "grunt-sass": "^1.0.0", 
    "open": "0.0.5" 
    }, 
    "engines": { 
    "node": ">=0.10.22", 
    "npm": ">=1.3.14" 
    }, 
    "scripts": { 
    "start": "node keystone.js" 
    }, 
    "main": "keystone.js" 
} 

UPDATE:我使用节点5.7和3.6 NPM

+0

你的npm版本是什么? –

+0

npm 3.6.0。这发生在一个亚马逊t2.micro实例 – danielrvt

+0

我在看这个建议更新到npm 3,但你已经在运行它。也许npm实际上没有足够的内存? Keystone安装了一大堆东西iirc https://github.com/twbs/bootstrap/issues/19070 –

您的服务器需要更多的内存用于npm。只需添加一些解释在https://*.com/a/17173973/124416

sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024 
sudo /sbin/mkswap /var/swap.1 
sudo /sbin/swapon /var/swap.1