2016-09-29 94 views
2

我在使用ElasticBeanStalk將我的Node.JS應用程序部署到AWS時遇到了一些麻煩。在運行npm install時多次調用回調

一旦部署開始,而(通過AWS默認)運行npm install腳本,我得到以下奇怪的錯誤:

[email protected] node_modules/material-ui 
    ├── [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    ├── [email protected] ([email protected]) 
    ├── [email protected] ([email protected], [email protected]) 
    ├── [email protected] 
    ├── [email protected] ([email protected]) 
    └── [email protected] ([email protected], [email protected], [email protected], [email protected]) 
    npm ERR! Linux 4.1.17-22.30.amzn1.x86_64 
    npm ERR! argv "/opt/elasticbeanstalk/node-install/node-v4.3.0-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v4.3.0-linux-x64/bin/npm" "--production" "install" 
    npm ERR! node v4.3.0 
    npm ERR! npm v2.14.12 

    npm ERR! Callback called more than once. 
    npm ERR! 
    npm ERR! If you need help, you may report this error at: 
    npm ERR!  <https://github.com/npm/npm/issues> 

    npm ERR! Please include the following file with any support request: 
    npm ERR!  /tmp/deployment/application/npm-debug.log 

誰能幫我調試這個問題?我已經花了太多時間試圖瞭解發生了什麼,但迄今爲止沒有結果。

謝謝!

回答

2

顯然有些AWS區域與npm有確實的連接問題(與此012d相關),我通過迫使npm通過http而不是https下載模塊來解決它。

爲了做到這一點,我添加一個.npmrc文件到我的項目有以下內容的根目錄:
registry= http://registry.npmjs.org/

感謝@Jason Livesay的提示和@danilojun幫我找到最佳的解決方案!

+1

我今天碰見這個問題爲好,在區域歐盟 - 部署西。發現在大多數情況下簡單地重試工作,所以它確實是間歇性的,但使用http似乎給出了更確定的結果。 – JHH

1

請粘貼完整的日誌。確認VM具有足夠的網絡和其他資源(免費/便宜的AWS東西被限制)。升級到最新的Node/npm。當您在github發佈中搜索該錯誤時,請在github npm回購問題上看到許多評論,例如https://github.com/npm/npm/issues/9418#issuecomment-170244027等。

1

我爲我正在處理的項目導出的另一個解決方案是檢查node_modules文件夾以獲取源代碼,然後禁用自動將npm安裝繼承到EB。這可以幫助具有嚴格依賴性的脆弱節點應用程序。

你需要下面的腳本添加到.ebextensions:

files: 
    "/opt/elasticbeanstalk/hooks/appdeploy/pre/50npm.sh": 
    mode: "000755" 
    owner: root 
    group: users 
    content: | 
     #!/bin/bash 
     #============================================================================== 
     # Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved. 
     # 
     # Licensed under the Amazon Software License (the "License"). You may not use 
     # this file except in compliance with the License. A copy of the License is 
     # located at 
     # 
     #  http://aws.amazon.com/asl/ 
     # 
     # or in the "license" file accompanying this file. This file is distributed on 
     # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or 
     # implied. See the License for the specific language governing permissions 
     # and limitations under the License. 
     #============================================================================== 

     #set -xe 
     #DO NOT RUN NPM...project contains node_modules 
     #/opt/elasticbeanstalk/containerfiles/ebnode.py --action npm-install 
0

更新npm解決了這個問題對我來說

npm i -g npm 
相關問題