Build keeps timing out with Node.js

Hi,

I’m relatively new to Netlify, i used it a lot with school and i am trying to use it for a current school project but i’m having trouble launching my branches.

One of them randomly worked:

It’s not a complicated build. super easy and should take no time but its not working for some reason.
my site name is: https://poogleproject.netlify.app

full log for my last one is here:
6:28:12 PM: build-image version: c1f0e3189beff44ebec7048bf7ab2e75cb09660b (focal)
6:28:12 PM: buildbot version: c1f0e3189beff44ebec7048bf7ab2e75cb09660b
6:28:12 PM: Fetching cached dependencies
6:28:12 PM: Failed to fetch cache, continuing with build
6:28:12 PM: Starting to prepare the repo for build
6:28:13 PM: No cached dependencies found. Cloning fresh repo
6:28:13 PM: git clone --filter=blob:none https://github.com/BenHoople/Poogle
6:28:13 PM: Preparing Git Reference refs/heads/master
6:28:14 PM: Parsing package.json dependencies
6:28:15 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: ‘dist’ versus ‘’ in the Netlify UI
6:28:15 PM: Different build command detected, going to use the one specified in the Netlify configuration file: ‘node index.js’ versus ‘yarn build’ in the Netlify UI
6:28:15 PM: Starting build script
6:28:15 PM: Installing dependencies
6:28:15 PM: Python version set to 2.7
6:28:16 PM: v16.19.1 is already installed.
6:28:16 PM: Now using node v16.19.1 (npm v8.19.3)
6:28:16 PM: Enabling Node.js Corepack
6:28:16 PM: Started restoring cached build plugins
6:28:16 PM: Finished restoring cached build plugins
6:28:16 PM: Attempting Ruby version 2.7.2, read from environment
6:28:17 PM: Using Ruby version 2.7.2
6:28:17 PM: Using PHP version 8.0
6:28:17 PM: Started restoring cached corepack dependencies
6:28:17 PM: Finished restoring cached corepack dependencies
6:28:17 PM: No npm workspaces detected
6:28:17 PM: Started restoring cached node modules
6:28:17 PM: Finished restoring cached node modules
6:28:17 PM: Installing npm packages using npm version 8.19.3
6:28:18 PM: npm WARN old lockfile
6:28:18 PM: npm WARN old lockfile The package-lock.json file was created with an old version of npm,
6:28:18 PM: npm WARN old lockfile so supplemental metadata must be fetched from the registry.
6:28:18 PM: npm WARN old lockfile
6:28:18 PM: npm WARN old lockfile This is a one-time fix-up, please be patient…
6:28:18 PM: npm WARN old lockfile
6:28:19 PM: npm WARN deprecated har-validator@5.1.5: this library is no longer supported
6:28:19 PM: npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See There’s Math.random(), and then there’s Math.random() · V8 for details.
6:28:19 PM: npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
6:28:19 PM: added 104 packages, and audited 105 packages in 1s
6:28:19 PM: 9 packages are looking for funding
6:28:19 PM: run npm fund for details
6:28:19 PM: found 0 vulnerabilities
6:28:19 PM: npm packages installed
6:28:19 PM: Started restoring cached go cache
6:28:19 PM: Finished restoring cached go cache
6:28:19 PM: go version go1.19.6 linux/amd64
6:28:20 PM: Detected 0 framework(s)
6:28:20 PM: Section completed: initializing
6:28:21 PM: ​
6:28:21 PM: Netlify Build
6:28:21 PM: ────────────────────────────────────────────────────────────────
6:28:21 PM: ​
6:28:21 PM: ❯ Version
6:28:21 PM: @netlify/build 29.5.8
6:28:21 PM: ​
6:28:21 PM: ❯ Flags
6:28:21 PM: baseRelDir: true
6:28:21 PM: buildId: 6405258a58aa2a00085c30bb
6:28:21 PM: deployId: 6405258a58aa2a00085c30bd
6:28:21 PM: ​
6:28:21 PM: ❯ Current directory
6:28:21 PM: /opt/build/repo
6:28:21 PM: ​
6:28:21 PM: ❯ Config file
6:28:21 PM: /opt/build/repo/netlify.toml
6:28:21 PM: ​
6:28:21 PM: ❯ Context
6:28:21 PM: production
6:28:21 PM: ​
6:28:21 PM: 1. build.command from netlify.toml
6:28:21 PM: ────────────────────────────────────────────────────────────────
6:28:21 PM: ​
6:28:21 PM: $ node index.js
6:28:21 PM: Server started on port 3000
7:14:13 PM: Build exceeded maximum allowed runtime

I’ve tried lots of different ports, looking through the forms and even tried using ChatGPT to help solve it but i cant understand what the problem is.

My netlify.toml file is this:
[build]
command = “node index.js”
publish = “dist”

my index.js ends with:
const port = process.env.PORT || 4000;

app.listen(port, () => console.log(Listening on ${port}));

and package.json scripts are this:
“scripts”: {
“test”: “echo "Error: no test specified" && exit 1”,
“build”: “node index.js”
},

I also put “yarn build app.js” in the build settings “Build Command” in the netlify dashboard.

If you can help me out that would be great, love using the site otherwise but this is very frustrating

@BenHoople It’s timing out because you aren’t performing a build, you’re starting a development server.

You shouldn’t be starting a server as part of the build process, only outputting static files and serverless functions.

Hi @BenHoople :wave:t6: welcome to the forums and thanks so much for reaching back out. To elaborate on what nathan said…

Performing a build typically involves compiling and bundling the source code and other required assets into a deployable artifact,. Starting a development server, on the other hand, involves running a local web server that can serve the application or website being developed.

Once you get the build configured you should be ready to deploy your app as normal. If you are still experiencing trouble have a read of our debugging guide below: