【问题标题】:Impossible to install bcrypt with npm on EC2无法在 EC2 上使用 npm 安装 bcrypt
【发布时间】:2015-05-20 03:53:07
【问题描述】:

在 Amazon EC2 实例上的 Ubuntu Server 14.04 上,我在执行 npm install 时出错。它未能安装 bcrypt("bcrypt": "^0.8.1"in 我的package.json)。

这是我遇到的错误:

> bcrypt@0.8.1 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 

【问题讨论】:

    标签: node.js amazon-web-services amazon-ec2 npm


    【解决方案1】:

    我只需要安装构建工具sudo apt-get install build-essential g++

    请注意,您必须apt-get update 以避免 apt-get 在 EC2 上出现任何问题(否则您最终可能会遇到 E: Failed to fetch…

    然后再次npm install,您就可以开始了!

    【讨论】:

      【解决方案2】:

      通过使用 gcc 4.4 安装和编译来修复,如下所示:

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

      参考:Level/levelup#224

      【讨论】:

        【解决方案3】:

        我最终在.ebextensions 文件夹中创建了一个00npm.config 文件。这将清除文件夹、设置环境变量并尝试再次构建。

        文件是:

        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
        

        【讨论】:

          猜你喜欢
          • 2020-03-31
          • 2014-11-09
          • 2018-03-16
          • 2012-12-26
          • 1970-01-01
          • 2021-08-24
          • 1970-01-01
          • 2012-01-02
          • 2021-05-24
          相关资源
          最近更新 更多