Beanstalk上使用Yarn安装软件包

Beanstalk上使用Yarn安装软件包

本文介绍了在Elastic Beanstalk上使用Yarn安装软件包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Yarn替代NPM在Elastic Beanstalk上安装软件包.我已经尝试过在网上找到的各种解决方案,但它们似乎都已过时,无法再使用.这是我现在所拥有的,如此要点所述.

I'd like to install packages on Elastic Beanstalk using Yarn as an alternative to NPM. I've tried all sorts of solutions I've found online, but they all appear to be outdated and no longer work. Here's what I have right now, as described in this gist.

files:
  '/opt/elasticbeanstalk/hooks/appdeploy/pre/49yarn.sh' :
    mode: '000755'
    owner: root
    group: root
    content: |
      #!/usr/bin/env bash
      set -euxo pipefail

      EB_APP_STAGING_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k app_staging_dir)

      if node -v; then
        echo 'Node already installed.'
      else
        echo 'Installing node...'
        curl --silent --location https://rpm.nodesource.com/setup_6.x | sudo bash -
        yum -y install nodejs
      fi

      if yarn -v; then
        echo 'Yarn already installed.'
      else
        echo 'Installing yarn...'
        wget https://dl.yarnpkg.com/rpm/yarn.repo -O /etc/yum.repos.d/yarn.repo
        yum -y install yarn
      fi

  '/opt/elasticbeanstalk/hooks/appdeploy/pre/50npm.sh' :
    mode: '000755'
    owner: root
    group: root
    content: |
      #!/usr/bin/env bash
      set -euxo pipefail

      yarn install --ignore-engines

推荐答案

这是我在Beanstalk上运行Yarn的目的:

This is what I use to run Yarn on Beanstalk :

commands:
  01_install_node:
    command: |
      sudo curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash -
      sudo yum -y install nodejs
  02_install_yarn:
    test: '[ ! -f /usr/bin/yarn ] && echo "Yarn not found, installing..."'
    command: |
      sudo wget https://dl.yarnpkg.com/rpm/yarn.repo -O /etc/yum.repos.d/yarn.repo
      sudo yum -y install yarn

container_commands:
  01_run_yarn:
    command: |
      yarn install
      yarn run encore production

这篇关于在Elastic Beanstalk上使用Yarn安装软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 00:17