Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

“Error: Please install pg package manually” when trying to run “npm run serve:dev”?

I'm trying to run an app with script npm run serve:dev but it gives an error Error: Please install pg package manually when trying to run npm run serve:dev

I already tried npm install -g pg','npm install -g pg-hstore

ERROR:

[email protected] serve:dev /home/qroach/kshitij-mag nodemon --ignore './src/' --exec babel-node --presets babel-preset-env ./server/bin/www

[nodemon] 1.18.10 [nodemon] to restart at any time, enter rs [nodemon] watching: . [nodemon] starting babel-node --presets babel-preset-env ./server/bin/www /home/qroach/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:81 throw new Error(Please install ${moduleName} package manually); ^

Error: Please install pg package manually at ConnectionManager._loadDialectModule (/home/qroach/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:81:15) at new ConnectionManager (/home/qroach/node_modules/sequelize/lib/dialects/postgres/connection-manager.js:18:24) at new PostgresDialect (/home/qroach/node_modules/sequelize/lib/dialects/postgres/index.js:14:30) at new Sequelize (/home/qroach/node_modules/sequelize/lib/sequelize.js:241:20) at Object. (/home/qroach/kshitij-mag/server/db/models/index.js:16:15) at Module._compile (internal/modules/cjs/loader.js:799:30) at loader (/usr/lib/node_modules/babel-cli/node_modules/babel-register/lib/node.js:144:5) at Object.require.extensions.(anonymous function) [as .js] (/usr/lib/node_modules/babel-cli/node_modules/babel-register/lib/node.js:154:7) at Module.load (internal/modules/cjs/loader.js:666:32) at tryModuleLoad (internal/modules/cjs/loader.js:606:12) at Function.Module._load (internal/modules/cjs/loader.js:598:3) at Module.require (internal/modules/cjs/loader.js:705:19) at require (internal/modules/cjs/helpers.js:14:16) at Object. (/home/qroach/kshitij-mag/server/controllers/AuthController.js:2:1) at Module._compile (internal/modules/cjs/loader.js:799:30) at loader (/usr/lib/node_modules/babel-cli/node_modules/babel-register/lib/node.js:144:5) at Object.require.extensions.(anonymous function) [as .js] (/usr/lib/node_modules/babel-cli/node_modules/babel-register/lib/node.js:154:7) at Module.load (internal/modules/cjs/loader.js:666:32) at tryModuleLoad (internal/modules/cjs/loader.js:606:12) at Function.Module._load (internal/modules/cjs/loader.js:598:3) at Module.require (internal/modules/cjs/loader.js:705:19) at require (internal/modules/cjs/helpers.js:14:16) [nodemon] app crashed - waiting for file changes before starting...

I expect it to run on using the script, but it just gives this error.

like image 868
qroach Avatar asked Mar 25 '19 15:03

qroach


2 Answers

I was also facing same issue. Try connecting your db like this:

import * as pg from 'pg';
import { Sequelize } from 'sequelize';

const sequelize = new Sequelize('postgres://admin:admin@localhost:5432/mydb', {
  dialectModule: pg
});

This worked for me. More info here

like image 178
Mateen Kiani Avatar answered Sep 16 '22 16:09

Mateen Kiani


Just install locally

npm install pg --save

like image 25
bereket gebredingle Avatar answered Sep 18 '22 16:09

bereket gebredingle