2016-03-08 113 views
0

我已經浪費了四個小時,試圖在生產環境中安裝我的'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 –

回答

0

您的服務器需要更多的內存用於npm。只需添加一些解釋在https://stackoverflow.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