Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sequelize.js can't find pg dependency when using webpack

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

like image 650
Boelensman1 Avatar asked Oct 11 '25 17:10

Boelensman1


1 Answers

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