问题
I'm trying to get Sequelize migrations to run on each deploy to Elastic Beanstalk.
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.
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?
Note: The ls -td commands above produce this result in my previous project:
/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
回答1:
I resolve this error by running the command in .ebextension/config_file.sh
files:
"/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
its works for me!!
来源:https://stackoverflow.com/questions/59739471/sequelize-migrations-error-while-running-in-elastic-beanstalk