在Elastic Beanstalk中运行时出现迁移迁移错误 [英] Sequelize migrations error while running in Elastic Beanstalk
问题描述
我正在尝试让Sequelize迁移在每次部署到Elastic Beanstalk时运行.
I'm trying to get Sequelize migrations to run on each deploy to Elastic Beanstalk.
我正在遵循 -vars-how-to-ac>有关Stack Overflow的其他答案,甚至是我过去从事过的其他项目,并且正在/.ebextensions文件夹中使用.config文件:>
I'm following the advice of the documentation, of other answers on Stack Overflow, and even a different project I've worked on in the past, and am using a .config file in my /.ebextensions folder:
container_commands:
00_node_binary:
command: "ln -sf `ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin/node /bin/node"
01_npm_binary:
command: "ln -sf `ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin/npm /bin/npm"
03_db_migrate:
command: ./node_modules/.bin/sequelize db:migrate
leader_only: true
当我尝试运行它时,出现此错误:
When I try to run it, I get this error:
ERROR [Instance: i-06991b5ec3283038a] Command failed on instance. Return code: 127 Output: /bin/sh: ./node_modules/.bin/sequelize: No such file or directory.
我还需要做什么(在.extensions,.elasticbeanstalk文件或EB的软件配置设置中),以便EB可以找到该模块并运行此命令?
What else do I need to do (either in .extensions, in .elasticbeanstalk file, or in EB's Software Configuration settings) so EB can find this module and run this command?
注意:上面的ls -td命令在我之前的项目中产生了以下结果:
Note: The ls -td commands above produce this result in my previous project:
/opt/elasticbeanstalk/node-install/node-v6.9.1-linux-x64
/opt/elasticbeanstalk/node-install/node-v6.9.1-linux-x64
这导致当前项目出现问题:
And this result in the current project I'm having trouble with:
/opt/elasticbeanstalk/node-install/node-v10.17.0-linux-x64
/opt/elasticbeanstalk/node-install/node-v10.17.0-linux-x64
推荐答案
我通过在.ebextension/config_file.sh
文件:
"/opt/elasticbeanstalk/hooks/appdeploy/pre/config_file.sh":
"/opt/elasticbeanstalk/hooks/appdeploy/pre/config_file.sh":
mode: "000755"
owner: root
group: root
content: |
#!/bin/bash
curl --silent --location https://rpm.nodesource.com/setup_12.x | sudo bash -
sudo yum -y install nodejs
然后
then
在应用程序目录中的终端上运行命令:
run command on terminal in your app directory:
./node_modules/.bin/sequelize db:migrate
它对我有用!
这篇关于在Elastic Beanstalk中运行时出现迁移迁移错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!