从 db/ 文件夹运行 knexfile.js

Ann*_*lee 4 node.js knex.js

我已经全局安装了nodejs包。

初始化viaknex init并将文件放入/db文件夹后,诸如此类的命令将knex migrate:latest不再起作用,因为knex找不到该文件。此外,knex 在我的根目录中创建 migrate 和 seed 文件夹

有什么建议如何配置 knex 让它始终查看/db文件夹吗?有什么方法可以通过 a 来做到这一点吗node-script

感谢您的回复!

Tea*_*hMe 7

您可以将配置文件位置指定为script

将其添加到 package.json 中

"migrate": "yarn knex migrate:latest --knexfile src/config/knexfile.js",
Run Code Online (Sandbox Code Playgroud)

我的 knexfile 位于 src/config 中。