Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jQatH-00065d-Jh for pgsql-general@arkaria.postgresql.org; Mon, 20 Apr 2020 18:11:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jQatG-0000ON-Fn for pgsql-general@arkaria.postgresql.org; Mon, 20 Apr 2020 18:11:30 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jQatE-0000Nq-OJ for pgsql-general@lists.postgresql.org; Mon, 20 Apr 2020 18:11:30 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jQat5-000886-Ba for pgsql-general@postgresql.org; Mon, 20 Apr 2020 18:11:27 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 2CB925C00F2; Mon, 20 Apr 2020 14:11:17 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 20 Apr 2020 14:11:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm2; bh=F EPbijNBJsCKCTT0lil+oRtlWKvjSuXrYXGSgveP+14=; b=far6W4ij0wll7ESIu m2re4lqRkSLaB6R8ZGnOvWNN15y4SXZ48TPdM3GTx7ylpxQ1SuPfnsVA/XYuchEr tetQpxOOb5mN4zJDj0mTYcCgupT/UlyQ0fhe5U4VlI6AKbhK56BxggJXsYQ5Xcep roC/nMLTvIGDTVYq4txOuoT3PEAV12ki88DyEMrLnreKsGMxaoOv0mlw55hMqvNd FG29GWew3D/AAC83CtrwpZk5UuEeUsNnJnKZk9Tl0WL+BO24sFYyhbW2LamOWBjL d1lIGjxNcDn3UqNwYy//og8rK30JKhxXtuMCaCey4HIz26H7Mjh7o1Tk357fki2I e5sXA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=FEPbijNBJsCKCTT0lil+oRtlWKvjSuXrYXGSgveP+ 14=; b=inbAO30kFs3Ly8HCkrM55undTntqZkjORFB8YMFDKkDUB7/Id6BugHeBW jRkUUX5fzYW/KDxVBFfg/Aj6DjL48LUyuZL0MPt0b/75WVpALcekvWM2a1UYN0iX hj1FgtMy4AMEGSgLt6MecH1KxhPfo4YVOom9lXe8NwrgYuNzJWybXDTISxvoAFZn 02G5YxWQMB3x2w8n+CXLVIJI6hXC4SlAGNxBarPk5HTibaVPHhq5Z9BqX0cjSltj thEyKD7mguW1TVLGmAhOLBi+XNQuzcj5hoaBEYmGepDWb01MUWSo0W+q3mUTvMLA JfJBrKd9q6cQVLXTMJVfDhhjCc4bg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrgeefgdduudeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthekredttdefjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucfkphepleejrdduudefrddvtdejrddufeeknecuvehluhhsthgvrhfuihiivgep tdenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklh grvhgvrhdrtghomh X-ME-Proxy: Received: from [192.168.1.10] (97-113-207-138.tukw.qwest.net [97.113.207.138]) by mail.messagingengine.com (Postfix) with ESMTPA id B3B493280060; Mon, 20 Apr 2020 14:11:15 -0400 (EDT) Subject: Re: Unable to connect to the database: TypeError: net.Socket is not a constructor To: Marco Ippolito , pgsql-general@postgresql.org References: From: Adrian Klaver Message-ID: Date: Mon, 20 Apr 2020 11:11:14 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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. > Looking forward to your kind help. > Marco -- Adrian Klaver adrian.klaver@aklaver.com