如何使用环境变量在 ElasticBeanstalk 上运行sequelize db:migrate?
运行sequelize migrate失败,因为它找不到.env
file.
{ Error: ENOENT: no such file or directory, open '.env'
我的 master.config 看起来像:
container_commands:
00_node_binary:
command: "ln -sf `ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin/node /bin/node"
00_npm_binary:
command: "ln -sf `ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin/npm /bin/npm"
01_migrations:
command: npm run migrate
leader_only: true
我的 package.json 包含
"migrate": "node_modules/sequelize-cli/bin/sequelize db:migrate"
Edit:
我刚刚发现环境变量发生了什么事。尝试运行迁移脚本而不npm
。它会是这样的:
./node_modules/.bin/sequelize db:migrate
这样,您将获得您期望的所有环境变量。
旧答案:
你确定你的.env
文件是否已提交到您的 git 存储库?一般来说,提交一个代码并不是一个好主意.env
git 并在生产中使用它。您应该改为在 Elastic Beanstalk 仪表板中的下设置环境变量Software Configuration
.
您还可以使用eb
命令行实用程序为记录在这里.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)