Sequelize (Nestjs) error connection Postgresql 8.4 - node.js

I have problem to connect in Postgres 8.4 version with Sequelize. Show me an error about not exist 'pg_range' (error message: relation "pg_range" dows not exist).
When I try connect in Postgre 9 it works. How can I connect in Postgres 8.4?
Technologies what I'm using:
Postgresql v8.4
#nestjs/core v7.5.1
#nestjs/sequelize v0.2.0
sequelize-typescript v0.2.0
sequelize v6.5.0
pg (Non-blocking PostgreSQL client) v8.5.1
Error:
[Nest] 22866 - 03/26/2021, 3:42:41 AM [SequelizeModule] Unable to connect to the database. Retrying (1)... +85ms
error: no existe la relación «pg_range»
at Connection.parseE (/.../node_modules/pg/lib/connection.js:567:11)
at Connection.parseMessage (/.../node_modules/pg/lib/connection.js:391:17)
at Socket.<anonymous> (/.../node_modules/pg/lib/connection.js:129:22)
at Socket.emit (events.js:198:13)
at addChunk (_stream_readable.js:288:12)
at readableAddChunk (_stream_readable.js:269:11)
at Socket.Readable.push (_stream_readable.js:224:10)
at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)

In the documentation, it is indicated the version of pg since pg_range exists (9.2)
enter link description here

Related

error: database "dbName" does not exist Node.js PostgreSQL

I'm just starting with Node.js and I'm following this tutorial https://dev.to/glaucia86/developing-a-crud-node-js-application-with-postgresql-4c9o
when setting .env file as suggested
DATABASE_URL=postgres://{db_username}:{db_password}#{host}:{port}/{db_name}
so
DATABASE_URL=postgres://vinnytwice:pass#localhost:5432/fixit
I start the server with npm start command when using Postman to send a Post request I get they error in console:
vinnytwice#Vinnys-iMac fixit_server_node % npm start
> fixit_server_node#1.0.0 start
> node server.js
App executing to port 3000
error: database "vinnytwice" does not exist
at Parser.parseErrorMessage (/Volumes/ProjectsSSD/FixitServer/fixit_server_node/node_modules/pg-protocol/dist/parser.js:287:98)
at Parser.handlePacket (/Volumes/ProjectsSSD/FixitServer/fixit_server_node/node_modules/pg-protocol/dist/parser.js:126:29)
at Parser.parse (/Volumes/ProjectsSSD/FixitServer/fixit_server_node/node_modules/pg-protocol/dist/parser.js:39:38)
at Socket.<anonymous> (/Volumes/ProjectsSSD/FixitServer/fixit_server_node/node_modules/pg-protocol/dist/index.js:11:42)
at Socket.emit (node:events:369:20)
at addChunk (node:internal/streams/readable:313:12)
at readableAddChunk (node:internal/streams/readable:288:9)
at Socket.Readable.push (node:internal/streams/readable:227:10)
at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
What am I doing wrong ?
Many thanks.
Finally found the problem, the .env file wasn't at the root of the project.

MongoNetworkError on node js and mongo db atlas

I have made a MEAN stack project. And this project was successfully run some days ago. But suddenly it gives MongoNetworkError. I do not change anything. I use mongo atlas. The error description is given below.
error MongoNetworkError: failed to connect to server [cluster0-shard-00-01-s9niu.mongodb.net:27017] on first connect [MongoNetworkError: connection 5 to cluster0-shard-00-01-s9niu.mongodb.net:27017 closed
at TLSSocket. (D:\Angular\meal-system-server\node_modules\mongodb\lib\core\connection\connection.js:372:9)
at Object.onceWrapper (events.js:300:26)
at TLSSocket.emit (events.js:210:5)
at net.js:658:12
at TCP.done (_tls_wrap.js:481:7) {
name: 'MongoNetworkError',
}]
at Pool. (D:\Angular\meal-system-server\node_modules\mongodb\lib\core\topologies\server.js:438:11)
at Pool.emit (events.js:210:5)
at D:\Angular\meal-system-server\node_modules\mongodb\lib\core\connection\pool.js:561:14
at D:\Angular\meal-system-server\node_modules\mongodb\lib\core\connection\pool.js:1008:9
at callback (D:\Angular\meal-system-server\node_modules\mongodb\lib\core\connection\connect.js:97:5)
at D:\Angular\meal-system-server\node_modules\mongodb\lib\core\connection\connect.js:124:7
at _callback (D:\Angular\meal-system-server\node_modules\mongodb\lib\core\connection\connect.js:349:5)
at Connection.errorHandler (D:\Angular\meal-system-server\node_modules\mongodb\lib\core\connection\connect.js:365:5)
at Object.onceWrapper (events.js:300:26)
at Connection.emit (events.js:210:5)
at TLSSocket. (D:\Angular\meal-system-server\node_modules\mongodb\lib\core\connection\connection.js:370:12)
at Object.onceWrapper (events.js:300:26)
at TLSSocket.emit (events.js:210:5)
at net.js:658:12
at TCP.done (_tls_wrap.js:481:7) {
name: 'MongoNetworkError',
}
Seems like an error with the certificate, mongodb atlas recently made changes in the certificates.
Which language you are using for this application and what is the version of the language ?
Please refer this document for more information : Mongodb Atlas Security

MongoError : command createIndexes requires authentication - mongodb npm

I have a project that I recently put in a production server (not live, but different from my development environment). I configured a mongoDB server with a password authentication.
When I start my Nodejs Application, my usual code retrieve correctly my mongoDB server, returning a client.db object successfully.
But I also have an error popping-in. Something that is not called inside my Nodejs application apparently.
[ERROR] { MongoError: command createIndexes requires authentication
at Connection.<anonymous> (/home/myaccount/myapp/node_modules/mongodb/lib/core/connection/pool.js:460:61)
at Connection.emit (events.js:189:13)
at processMessage (/home/myaccount/myapp/node_modules/mongodb/lib/core/connection/connection.js:368:10)
at Socket.<anonymous> (/home/myaccount/myapp/node_modules/mongodb/lib/core/connection/connection.js:537:15)
at Socket.emit (events.js:189:13)
at addChunk (_stream_readable.js:284:12)
at readableAddChunk (_stream_readable.js:265:11)
at Socket.Readable.push (_stream_readable.js:220:10)
at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
ok: 0,
errmsg: 'command createIndexes requires authentication',
code: 13,
codeName: 'Unauthorized',
name: 'MongoError',
[Symbol(mongoErrorContextSymbol)]: {} }
nothing in the error is pointing toward something I created, it's only about the mongodb npm library. It also giving this error even if a delete every MongoDB connexion related code (but not the mongodb library load).
Do you have any idea how to fix this ?
Okay it's my fault. I had another connexion point that I didn't changed from my express sessions. It's fixed now.
It's just weird the error didn't point toward that module..

Offset error at the launch of a nodejs api application

I'm setting up an api application based on NodeJS and the ORM Sequelize. Everything work fine on my local computer (Windows), but when I want to install this app on a AWS EC2 Linux Instance, I'm encountering this error at the launch of the app :
internal/buffer.js:53
throw new ERR_OUT_OF_RANGE(type || 'offset',
^
RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. It must be >= 0 and <= 5. Received 9
at boundsError (internal/buffer.js:53:9)
at Uint8Array.readUInt32LE (internal/buffer.js:109:5)
at Packet.readInt32 (/home/ec2-user/live/CodexAvatarAPI/node_modules/mysql2/lib/packets/packet.js:103:24)
at Function.fromPacket (/home/ec2-user/live/CodexAvatarAPI/node_modules/mysql2/lib/packets/handshake.js:59:32)
at ClientHandshake.handshakeInit (/home/ec2-user/live/CodexAvatarAPI/node_modules/mysql2/lib/commands/client_handshake.js:92:40)
at ClientHandshake.execute (/home/ec2-user/live/CodexAvatarAPI/node_modules/mysql2/lib/commands/command.js:39:22)
at Connection.handlePacket (/home/ec2-user/live/CodexAvatarAPI/node_modules/mysql2/lib/connection.js:449:32)
at PacketParser.Connection.packetParser.p [as onPacket] (/home/ec2-user/live/CodexAvatarAPI/node_modules/mysql2/lib/connection.js:72:12)
at PacketParser.executeStart (/home/ec2-user/live/CodexAvatarAPI/node_modules/mysql2/lib/packet_parser.js:75:16)
at Socket.Connection.stream.on.data (/home/ec2-user/live/CodexAvatarAPI/node_modules/mysql2/lib/connection.js:79:25)
at Socket.emit (events.js:182:13)
at addChunk (_stream_readable.js:283:12)
at readableAddChunk (_stream_readable.js:264:11)
at Socket.Readable.push (_stream_readable.js:219:10)
at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
I've done some research but found nothing useful for now. To my understanding (i'm a beginner with node), the problem seems to be more in the mysql2 component than in the core of NodeJS itself, but I'm not sure where to search exactly.
This error happen juste before synchronizing the database structure with what has been defined in the code. Normally I have to see database update at this point.

node.js db-migrate create extension issue

I use the db-migrate to create the table. I have a sql statement.
CREATE EXTENSION IF NOT EXISTS pgcrypto;
But I got a error.
[ERROR] AssertionError [ERR_ASSERTION]: ifError got unwanted exception: could not load library "/Users/manlokwong/PostgreSQL/pg96/lib/postgresql/pgcrypto.so": dlopen(/Users/manlokwong/PostgreSQL/pg96/lib/postgresql/pgcrypto.so, 10): Library not loaded: /opt/pgbin-build/pgbin/shared/osx_64/lib/libcrypto.1.0.0.dylib
Referenced from: /Users/manlokwong/PostgreSQL/pg96/lib/postgresql/pgcrypto.so
Reason: image not found
at Connection.parseE (/usr/local/lib/node_modules/db-migrate-pg/node_modules/pg/lib/connection.js:553:11)
at Connection.parseMessage (/usr/local/lib/node_modules/db-migrate-pg/node_modules/pg/lib/connection.js:378:19)
at Socket. (/usr/local/lib/node_modules/db-migrate-pg/node_modules/pg/lib/connection.js:119:22)
at Socket.emit (events.js:182:13)
at addChunk (_stream_readable.js:280:12)
at readableAddChunk (_stream_readable.js:265:11)
at Socket.Readable.push (_stream_readable.js:220:10)
at TCP.onread (net.js:638:20)
The extension is unable to load an OpenSSL shared library at /opt/pgbin-build/pgbin/shared/osx_64/lib/libcrypto.1.0.0.dylib. Try fully reinstalling your PostgreSQL distribution or using one from Homebrew.

Resources