Skip to content
This repository was archived by the owner on May 10, 2021. It is now read-only.
This repository was archived by the owner on May 10, 2021. It is now read-only.

Issues with sequelize #33

Closed
Closed
@Tanner-Scadden

Description

@Tanner-Scadden

I love your guys package and really enjoy using netlify and nextjs with an api.

I've ran into an issue where I can't build using this package when I also am using sequelize. I am wondering if I am able to get some help or possibly contribute to this package to get it working.

ModuleNotFoundError: Module not found: Error: Can't resolve 'pg-native' in '/opt/build/repo/node_modules/pg/lib/native'

I've tried altering my next.config.js to try and work around this errors. It would build locally and on netlify, but fail when creating the netlify functions with the same errors.

module.exports = { // Target must be serverless target: 'serverless', webpack: (config, { webpack }) => { // Note: we provide webpack above so you should not require it // Perform customizations to webpack config config.plugins.push(new webpack.IgnorePlugin(/\/__tests__\//)); config.externals = [ ...config.externals, 'pg', 'sqlite3', 'tedious', 'pg-hstore', ]; // Important: return the modified config return config; }, };

{ "name": "with-typescript", "version": "1.0.0", "scripts": { "dev": "next", "build": "next build", "start": "next start", "postbuild": "next-on-netlify", "type-check": "tsc" }, "dependencies": { "@material-ui/core": "^4.11.0", "@material-ui/icons": "^4.9.1", "@types/lodash": "^4.14.159", "@types/nodemailer": "^6.4.0", "@types/sequelize": "^4.28.9", "axios": "^0.19.2", "babel-plugin-react-intl": "^8.1.1", "lodash": "^4.17.19", "netlify-plugin-cache-nextjs": "^1.5.0", "next": "latest", "next-on-netlify": "^2.3.2", "nodemailer": "^6.4.11", "notistack": "^0.9.17", "pg": "^8.3.0", "pg-hstore": "^2.3.3", "react": "^16.13.1", "react-dom": "^16.12.0", "react-intl-hooks": "^1.0.11", "sequelize": "^6.3.4" }, "devDependencies": { "@types/node": "^12.12.21", "@types/pg": "^7.14.4", "@types/react": "^16.9.46", "@types/react-dom": "^16.9.8", "typescript": "^3.9.7" }, "license": "ISC" }

I've tried to create the sequelize connection multiple different ways but build is always failing. Here is what I have currently:

const sequelize = new Sequelize({ database, username, password, port, host: process.env.HOST, protocol: 'postgres', dialect: 'postgres', dialectModule: require('pg'), dialectOptions: { ssl: { rejectUnauthorized: false, }, }, logging: false, });

Any help on this issue would be incredible. Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions