Node JS won't start - trying to run a server on netlify

Hello. Please note I am a complete novice when it comes to Nodejs and this site. I have been wanting to build a connect 4 game that was multiplayer and for that I run a node server with socket io. So far I only have the html part functioning while the server runs and does nothing. For some reason though it keeps saying deploy in progress and won’t finish deploying. Any help would be greatly appreciated.

Console Log
1:16:34 PM: Build ready to start
1:16:36 PM: build-image version: 9e0f207a27642d0115b1ca97cd5e8cebbe492f63
1:16:36 PM: build-image tag: v3.3.2
1:16:36 PM: buildbot version: 38cc4984170575781fef71bee035f0855939acb8
1:16:36 PM: Fetching cached dependencies
1:16:36 PM: Starting to download cache of 600.4KB
1:16:36 PM: Finished downloading cache in 70.511898ms
1:16:36 PM: Starting to extract cache
1:16:36 PM: Finished extracting cache in 18.146224ms
1:16:36 PM: Finished fetching cache in 89.379441ms
1:16:36 PM: Starting to prepare the repo for build
1:16:37 PM: Preparing Git Reference refs/heads/master
1:16:37 PM: Starting build script
1:16:37 PM: Installing dependencies
1:16:39 PM: Downloading and installing node v10.16.3…
1:16:39 PM: Downloading https://nodejs.org/dist/v10.16.3/node-v10.16.3-linux-x64.tar.xz
1:16:39 PM:

9.5%

1:16:39 PM:
##############################################
1:16:39 PM: 64.0%
1:16:39 PM:
################################
1:16:39 PM: ################################### 94.4%
1:16:39 PM:
######################################################################## 100
1:16:39 PM: .0%
1:16:40 PM: Computing checksum with sha256sum
1:16:40 PM: Checksums matched!
1:16:43 PM: Now using node v10.16.3 (npm v6.9.0)
1:16:43 PM: Attempting ruby version 2.6.2, read from environment
1:16:45 PM: Using ruby version 2.6.2
1:16:45 PM: Using PHP version 5.6
1:16:45 PM: Started restoring cached node modules
1:16:45 PM: Finished restoring cached node modules
1:16:45 PM: Installing NPM modules using NPM version 6.9.0
1:16:52 PM: npm
1:16:52 PM: notice created a lockfile as package-lock.json. You should commit this file.
1:16:52 PM: npm WARN
1:16:52 PM: connex4@0.0.1 No repository field.
1:16:52 PM: npm WARN connex4@0.0.1 No license field.
1:16:52 PM: added 87 packages from 58 contributors and audited 203 packages in 6.123s
1:16:52 PM: found 0 vulnerabilities
1:16:52 PM: NPM modules installed
1:16:53 PM: Started restoring cached go cache
1:16:53 PM: Finished restoring cached go cache
1:16:53 PM: unset GOOS;
1:16:53 PM: unset GOARCH;
1:16:53 PM: export GOROOT=‘/opt/buildhome/.gimme/versions/go1.12.linux.amd64’;
1:16:53 PM: export PATH=“/opt/buildhome/.gimme/versions/go1.12.linux.amd64/bin:${PATH}”;
1:16:53 PM: go version >&2;
1:16:53 PM: export GIMME_ENV=‘/opt/buildhome/.gimme/env/go1.12.linux.amd64.env’;
1:16:53 PM: go version go1.12 linux/amd64
1:16:53 PM: Installing missing commands
1:16:53 PM: Verify run directory
1:16:53 PM: Executing user command: npm run start
1:16:53 PM: > connex4@0.0.1 start /opt/build/repo
1:16:53 PM: > node index.js
1:16:54 PM: listening on *:3000

Hi @Txlon5,

Welcome and I will try to help explain.

What Netlify does

The Netlify hosting service does not run a NodeJS server. It is serving up your static site on their CDN (content delivery network). The service hosts static assets. Sites and applications access backend servers through API’s and Netlify offers Netlify Functions for added superpowers if you need them as a plugin.

But it is running NodeJS when there is a deploy

During the deploy process of a GitHub, Gitlab or Bitbucket connected site, Netlify creates a build environment running NodeJS so you can build your site during the deploy process. The site is built into a directory or location for the deploy to the Netlify CDN.

What does starting a server on deploy actually do?

When there is a server started and running on Netlify in the build container, it is doing nothing other than hanging up your build process waiting for a response that will never come. A server started during local development workflow allows the ability to test a site as if it was running on the CDN.

Can there be dynamic data in a Netlify hosted application?

Sure, but this data needs to be accessed through a fetch/request from the client’s browser using javascript. The application will make this call to an API on a remote server. It can be a third party service or you have the option of using Netlify Functions if you want to.

Hope this helps clear things up a little.

3 Likes