Reputation: 6363
Trying to configure Sequelize with a Postgres database. I'm using Webpack to bundle my app. When I integrate Sequelize with just:
var Sequelize = require('sequelize');
I get the following errors in my terminal:
WARNING in ./~/sequelize/lib/sequelize.js
Critical dependencies:
654:60-73 the request of a dependency is an expression
@ ./~/sequelize/lib/sequelize.js 654:60-73
WARNING in ./~/sequelize/lib/dialects/mssql/connection-manager.js
Critical dependencies:
17:15-71 the request of a dependency is an expression
@ ./~/sequelize/lib/dialects/mssql/connection-manager.js 17:15-71
WARNING in ./~/sequelize/lib/dialects/mysql/connection-manager.js
Critical dependencies:
18:17-60 the request of a dependency is an expression
@ ./~/sequelize/lib/dialects/mysql/connection-manager.js 18:17-60
WARNING in ./~/sequelize/lib/dialects/postgres/connection-manager.js
Critical dependencies:
18:41-92 the request of a dependency is an expression
18:102-153 the request of a dependency is an expression
@ ./~/sequelize/lib/dialects/postgres/connection-manager.js 18:41-92 18:102-153
WARNING in ./~/sequelize/lib/dialects/sqlite/connection-manager.js
Critical dependencies:
22:15-71 the request of a dependency is an expression
@ ./~/sequelize/lib/dialects/sqlite/connection-manager.js 22:15-71
WARNING in ./~/sequelize/lib/dialects/mysql/connection-manager.js
Module not found: Error: Cannot resolve module 'mysql' in /Users/dace/Code/personal/airthere/node_modules/sequelize/lib/dialects/mysql
@ ./~/sequelize/lib/dialects/mysql/connection-manager.js 20:17-33
ERROR in ./~/sequelize/package.json
Module parse failed: /Users/dace/Code/personal/airthere/node_modules/sequelize/package.json Line 2: Unexpected token :
You may need an appropriate loader to handle this file type.
| {
| "_args": [
| [
| "sequelize@^3.19.1",
@ ./~/sequelize/lib/sequelize.js 245:20-46
ERROR in ./~/moment-timezone/data/packed/latest.json
Module parse failed: /Users/dace/Code/personal/airthere/node_modules/moment-timezone/data/packed/latest.json Line 2: Unexpected token :
You may need an appropriate loader to handle this file type.
| {
| "version": "2015g",
| "zones": [
| "Africa/Abidjan|LMT GMT|g.8 0|01|-2ldXH.Q|48e5",
@ ./~/moment-timezone/index.js 2:15-51
I think this is a webpack related issue, since I can get Sequelize running in project that doesn't use webpack. I'm just not sure what it is. It looks like the last two might be related to needing loaders for webpack (not sure which ones) and the other warnings are dependency related or the dependency is an expression (not sure what that means).
Any and all help is greatly appreciated. Thanks.
Upvotes: 0
Views: 2305
Reputation: 6363
UPDATE: It was pointed out to me that this was being done on the client side and that's the wrong way to go about this. I moved this Sequelize database configuration into my server.js file (that holds my express configuration) and it works well as webpack no longer interfaces with it:
const express = require('express');
const app = express();
var Sequelize = require('sequelize');
var connection = new Sequelize('dev', 'dace', 'root', {
dialect: 'postgres',
});
const PORT = (process.env.PORT || 3000);
app.get('/', function(req, res) {
var Article = connection.define('article', {
name: Sequelize.STRING,
})
connection.sync().then(function() {
Article.create({
name: 'Dace'
});
});
})
app.listen(PORT, function() {
console.log(`Listening on port ${PORT}...`);
});
Not how it should ultimately be configured, but just enough to get a working example of what I'm trying to do.
Upvotes: 1