gpt4 book ai didi

node.js - 弹性 beantalk 上的 npm 全局安装

转载 作者:IT老高 更新时间:2023-10-28 23:26:23 25 4
gpt4 key购买 nike

我在 aws elastic beanstalk 上全局安装 pm2 时遇到问题。我为安装 pm2 创建了以下脚本:

option_settings:
- option_name: NODE_ENV
value: production
container_commands:
01_enable_rootaccess:
command: echo Defaults:root \!requiretty >> /etc/sudoers
02_install_imagemagic:
command: yum install -y ImageMagick
03_download_new_relic:
command: rpm -Uvh http://download.newrelic.com/pub/newrelic/el5/i386/newrelic-repo-5-3.noarch.rpm
ignoreErrors: true
04_install_new_relic:
command: yum install -y newrelic-sysmond
ignoreErrors: true
05_add_license_key:
command: /usr/sbin/nrsysmond-config --set license_key=xxxxxxx
ignoreErrors: true
06_start_new_relic:
command: /etc/init.d/newrelic-sysmond start
ignoreErrors: true
07_install_pm2:
command: sudo /opt/elasticbeanstalk/node-install/node-v0.10.26-linux-x64/bin/npm install pm2 -g
ignoreErrors: true
08_stop_old_pm2_processes:
command: sudo /opt/elasticbeanstalk/node-install/node-v0.10.26-linux-x64/bin/pm2 delete all
ignoreErrors: true
09_start_pm2:
command: sudo /opt/elasticbeanstalk/node-install/node-v0.10.26-linux-x64/bin/pm2 startup -u ec2-user
ignoreErrors: true

我尝试对命令 8 和 9 仅使用“pm2 delete all”和“pm2 startup”,但我只是找不到命令。当我给出 pm2 的特定路径(我登录到 ec2 并验证)时,我得到“第 4 行:执行::未找到”。知道我在这里做错了什么吗?提前感谢您的帮助!

最佳答案

我设法在弹性 beantalk 上全局安装 pm2,并在 .ebextensions/your_file_name.config 文件中嵌入了以下代码片段

container_commands:
01_node_symlink:
command: "ln -sf `ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin/node /bin/node"
02_npm_symlink:
command: "ln -sf `ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin/npm /bin/npm"
03_pm2_install:
command: "if [ ! -e /bin/pm2 ]; then npm install pm2 -g; fi"
ignoreErrors: true

关于node.js - 弹性 beantalk 上的 npm 全局安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23407357/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com