Reputation: 314
When requiring sequelize I get some warning about "Critical dependencies". After running the app I get the following error: "Error: The dialect postgres is not supported. (Error: Please install 'pg' module manually)".
Both pg and pg-hstore are however installed.
I think the problem is with sequelize.js dynamically looking for postgres. I tried to use the webpack ContextReplacementPlugin, but I have no idea how.
I'm using the React Starter Kit boilerplate. The code that causes the problem is nothing more than this:
var Sequelize = require('sequelize');
//get the database info
import { dbModelLocation} from '../config';
import { dbConnectionConfig } from '../config';
var sequelize = new Sequelize(dbConnectionConfig.name,
dbConnectionConfig.user,
dbConnectionConfig.pass,
dbConnectionConfig.options);
The exact warnings I get from webpack are:
WARNING in ./~/sequelize/lib/sequelize.js Critical dependencies: 636:60-73 the request of a dependency is an expression @ ./~/sequelize/lib/sequelize.js 636:60-73
WARNING in ./~/sequelize/lib/dialects/mssql/connection-manager.js Critical dependencies: 15:15-71 the request of a dependency is an expression @ ./~/sequelize/lib/dialects/mssql/connection-manager.js 15:15-71
WARNING in ./~/sequelize/lib/dialects/mysql/connection-manager.js Critical dependencies: 15:15-69 the request of a dependency is an expression @ ./~/sequelize/lib/dialects/mysql/connection-manager.js 15:15-69
WARNING in ./~/sequelize/lib/dialects/postgres/connection-manager.js Critical dependencies: 16:41-92 the request of a dependency is an expression 16:102-153 the request of a dependency is an expression @ ./~/sequelize/lib/dialects/postgres/connection-manager.js 16:41-92 16:102-153
WARNING in ./~/sequelize/lib/dialects/sqlite/connection-manager.js Critical dependencies: 19:15-71 the request of a dependency is an expression @ ./~/sequelize/lib/dialects/sqlite/connection-manager.js 19:15-71
Upvotes: 4
Views: 8775
Reputation: 5961
If you're like me ran into the same issue when using Webpack with Sqlite3 or MySQL, you'll need to use externals
and define the dependencies:
var config = {
externals: ['pg', 'sqlite3', 'tedious', 'pg-hstore'],
};
Further information can be found in the following:
Upvotes: 3
Reputation: 267
According to the Webpack author the solution is to ignore node_modules
while bundling.
Upvotes: -1
Reputation: 219
Sorry for answer on old questions, but I got the same error when I tried to use sequelize migrations. May be it will help someone.
You have to install 'pg' package globally and it will be work:
npm install -g pg
Upvotes: 1