node.js - 在 Elastic Beanstalk 上使用 Yarn 安装包
问题描述
我想使用 Yarn 作为 NPM 的替代品在 Elastic Beanstalk 上安装软件包。我已经尝试了我在网上找到的各种解决方案,但它们似乎都已经过时并且不再有效。这就是我现在所拥有的,如本 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 的:
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
推荐阅读
- reactjs - 如何使用 React Hooks 使用 Spring WebFlux 服务
- html - 如何垂直放置元素而不是相互叠加
- mysql - 使用netbeans从mysql中检索数据
- sql - 在 SQL 中使用 NOT IN 时,使用 != 会得到不同的结果
- ios - 可以使用 HKWorkoutBuilder 对象在 iPhone(没有配对手表)中收集锻炼数据吗?
- php - 数组数组上的array_diff() 返回错误结果
- java - EAP 7.2 上的目标“不存在”错误
- javascript - 多次模态渲染
- java - Null-Check & isPresent - 名称不同但问题相同?
- excel - 刷新外部链接源的数据(数据透视表)而不打开它(来自第二个文件)