2015-03-17 33 views
5

Trên Máy chủ Ubuntu 14.04 trên phiên bản Amazon EC2, tôi gặp lỗi khi thực hiện npm install. Không cài đặt được bcrypt ("bcrypt": "^0.8.1" trong số package.json) của tôi.Không thể cài đặt bcrypt với npm trên EC2

Đây là lỗi tôi đã:

> [email protected] install /home/ubuntu/app/node_modules/bcrypt 
> node-gyp rebuild 

child_process: customFds option is deprecated, use stdio instead. 
make: Entering directory `/home/ubuntu/app/node_modules/bcrypt/build' 
    CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o 
make: g++: Command not found 
make: *** [Release/obj.target/bcrypt_lib/src/blowfish.o] Error 127 
make: Leaving directory `/home/ubuntu/app/node_modules/bcrypt/build' 
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2 
gyp ERR! stack  at ChildProcess.onExit (/home/ubuntu/node-v0.12.0-linux-x64/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23) 
gyp ERR! stack  at ChildProcess.emit (events.js:110:17) 
gyp ERR! stack  at Process.ChildProcess._handle.onexit (child_process.js:1067:12) 
gyp ERR! System Linux 3.13.0-44-generic 
gyp ERR! command "node" "/home/ubuntu/node-v0.12.0-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" 
gyp ERR! cwd /home/ubuntu/app/node_modules/bcrypt 
gyp ERR! node -v v0.12.0 
gyp ERR! node-gyp -v v1.0.2 
gyp ERR! not ok 

Trả lời

3

Tôi chỉ phải cài đặt các công cụ xây dựng sudo apt-get install build-essential g++

Lưu ý rằng bạn phải apt-get update để tránh bất kỳ vấn đề với apt-get trên EC2 (nếu không bạn có thể kết thúc với E: Failed to fetch…

Sau đó npm install một lần nữa và bạn tốt để đi!

1

Cố định bằng cách cài đặt và biên dịch với gcc 4.4 như thế này:

yum install gcc44 gcc44-c++ 
export CC="gcc44" 
export CXX="g++44" 
npm install -g level 

tham khảo: tốt nghiệp/Thực levelup # 224

0

tôi đã kết thúc việc tạo ra một tập tin trong thư mục 00npm.config.ebextensions. Thao tác này sẽ xóa thư mục, đặt biến môi trường và cố gắng tạo lại.

Các tập tin là:

files: 
    "/opt/elasticbeanstalk/hooks/appdeploy/pre/50npm.sh" : 
    mode: "000775" 
    owner: root 
    group: root 
    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. 
     #============================================================================== 

     export HOME=/home/ec2-user 
     export USERPROFILE=/home/ec2-user 

     sudo rm -rf /tmp/deployment/application/node_modules/bcrypt 

     set -xe 

     /opt/elasticbeanstalk/containerfiles/ebnode.py --action npm-install 
Các vấn đề liên quan