admin管理员组文章数量:1400134
I have created a separate helper library to work with databases.
I am then importing this library in my project. When I am trying to create a db connection using mysql dialect, it says the following: Please install mysql2 package manually
I have installed mysql2 library in my root project but it still does not work. Do I have to install mysql2 in the helper library as well ? Is there any way to install a dependency to be visible in other libraries as well ?
I am trying to keep it as small as possible. I want the library to be configurable from the root application.
I have created a separate helper library to work with databases.
I am then importing this library in my project. When I am trying to create a db connection using mysql dialect, it says the following: Please install mysql2 package manually
I have installed mysql2 library in my root project but it still does not work. Do I have to install mysql2 in the helper library as well ? Is there any way to install a dependency to be visible in other libraries as well ?
I am trying to keep it as small as possible. I want the library to be configurable from the root application.
Share Improve this question asked Jan 11, 2021 at 9:59 Tomas LukacTomas Lukac 2,2753 gold badges24 silver badges45 bronze badges1 Answer
Reset to default 11I found the solution. Sequelize accepts the dialect option in the constructor. All you need to do is provide it:
const connection = new Sequelize({
host: 'localhost',
username: 'root',
password: 'root',
database: 'mydb',
dialect: 'mysql',
dialectModule: require('mysql2'), <========= IMPORTING DIALECT
benchmark: true
})
本文标签: javascriptSequelizePlease install mysql2 package manuallyStack Overflow
版权声明:本文标题:javascript - Sequelize - Please install mysql2 package manually - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744163109a2593428.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论