Re: Unable to connect to the database: TypeError: net.Socket is not a constructor

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Marco Ippolito <ippolito(dot)marco(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Unable to connect to the database: TypeError: net.Socket is not a constructor
Date: 2020-04-20 19:21:58
Message-ID: ffa8edf6-fa82-1c08-82b5-f94905e85ac7@aklaver.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 4/20/20 11:29 AM, Marco Ippolito wrote:
>
>
> Il giorno lun 20 apr 2020 alle ore 20:11 Adrian Klaver
> <adrian(dot)klaver(at)aklaver(dot)com <mailto:adrian(dot)klaver(at)aklaver(dot)com>> ha scritto:
>
> On 4/20/20 10:50 AM, Marco Ippolito wrote:
> > I'm trying to connect to a postgres database (Postgresql-11)
> within my
> > nodejs-vue.js app, but in console I'm getting this error:
> >
> >      [HMR] Waiting for update signal from WDS...
> >      pg.js?c8c2:27 Unable to connect to the database: TypeError:
> > net.Socket is not a constructor
>
> >      Environment Info:
> >
> >        System:
> >          OS: Linux 5.3 Ubuntu 18.04.4 LTS (Bionic Beaver)
> >          CPU: (8) x64 Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz
> >        Binaries:
> >          Node: 12.15.0 - ~/.nvm/versions/node/v12.15.0/bin/node
> >          Yarn: 1.22.4 - ~/.nvm/versions/node/v12.15.0/bin/yarn
> >          npm: 6.14.4 - ~/.nvm/versions/node/v12.15.0/bin/npm
> >        Browsers:
> >          Chrome: 81.0.4044.92
> >          Firefox: 75.0
> >        npmGlobalPackages:
> >          @vue/cli: 4.2.3
> >
> > So... how to solve the problem?
>
>  From what I can gather the issue is that the code is running in the
> context of the browser and net.Socket is not supported there. It seems
> that the fix is to run the database code in node.js and pass the data
> from there to vue.js. Honestly, this whole reactive code thing is still
> something I'm wrapping my head around. I did find some tutorials
> searching on 'node.js vue.js Sequelize postgresql'. Most seemed to use
> express.js as the glue between node and vue.
>
>
> Thank you Adrian for your very kind response.
> express.js is the server framework for node.js
> So...two questions come in mind:
>   am I obliged to use express.js as glue between node and vue, if I
> already use nginx as web server?
>   And if I'm obliged to use another web server apart from nginx to glue
> node and vue, would it be possible to use a golang web-server,
>   which could be a further complication but would have its own positive
> sides?

I have no idea, this is not something I normally deal with. I would
guess you will get better answers from a node.js forum.

>
> Marco
>
>
>
> > Looking forward to your kind help.
> > Marco
>
>
> --
> Adrian Klaver
> adrian(dot)klaver(at)aklaver(dot)com <mailto:adrian(dot)klaver(at)aklaver(dot)com>
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tim Cross 2020-04-20 22:47:11 Re: Unable to connect to the database: TypeError: net.Socket is not a constructor
Previous Message Marco Ippolito 2020-04-20 18:29:05 Re: Unable to connect to the database: TypeError: net.Socket is not a constructor