Netlify build failing with npm ERR! code ENOWORKSPACES

Netlify site name: kimchinese

Full build error log:
7:51:26 AM: Build ready to start

7:51:28 AM: build-image version: d2c6dbeac570350a387d832f64bc980dc964ad65 (focal)

7:51:28 AM: build-image tag: v4.8.0

7:51:28 AM: buildbot version: e58b6be665675c0f99b33132a8c1eec1f775eba1

7:51:28 AM: Fetching cached dependencies

7:51:28 AM: Failed to fetch cache, continuing with build

7:51:28 AM: Starting to prepare the repo for build

7:51:29 AM: No cached dependencies found. Cloning fresh repo

7:51:29 AM: git clone GitHub - jugheadjones10/kimchinese

7:51:30 AM: Preparing Git Reference refs/heads/main

7:51:31 AM: Parsing package.json dependencies

7:51:31 AM: Different build dir detected, going to use the one specified in the Netlify configuration file: ‘packages/frontend’ versus ‘’ in the Netlify UI

7:51:31 AM: Different publish path detected, going to use the one specified in the Netlify configuration file: ‘packages/frontend’ versus ‘’ in the Netlify UI

7:51:31 AM: Different functions path detected, going to use the one specified in the Netlify configuration file: ‘packages/frontend/netlify/functions’ versus ‘’ in the Netlify UI

7:51:32 AM: Starting build script

7:51:32 AM: Installing dependencies

7:51:32 AM: Python version set to 2.7

7:51:32 AM: v16.14.2 is already installed.

7:51:33 AM: Now using node v16.14.2 (npm v8.5.0)

7:51:33 AM: Started restoring cached build plugins

7:51:33 AM: Finished restoring cached build plugins

7:51:33 AM: Attempting ruby version 2.7.2, read from environment

7:51:34 AM: Using ruby version 2.7.2

7:51:34 AM: Using PHP version 8.0

7:51:35 AM: No npm workspaces detected

7:51:35 AM: Started restoring cached node modules

7:51:35 AM: Finished restoring cached node modules

7:51:35 AM: Installing NPM modules using NPM version 8.5.0

7:51:35 AM: npm ERR! code ENOWORKSPACES

7:51:35 AM: npm ERR! This command does not support workspaces.

7:51:35 AM: npm ERR! A complete log of this run can be found in:

7:51:35 AM: npm ERR! /opt/buildhome/.npm/_logs/2022-04-24T22_51_35_768Z-debug-0.log

7:52:04 AM: npm ERR! Cannot set properties of null (setting ‘dev’)

7:52:04 AM: npm ERR! A complete log of this run can be found in:

7:52:04 AM: npm ERR! /opt/buildhome/.npm/_logs/2022-04-24T22_51_36_051Z-debug-0.log

7:52:04 AM: Error during NPM install

7:52:04 AM: Creating deploy upload records

7:52:04 AM: Build was terminated: Build script returned non-zero exit code: 1

7:52:05 AM: Failing build: Failed to build site

7:52:05 AM: Failed during stage ‘building site’: Build script returned non-zero exit code: 1 (Search results for '"non-zero exit code: 1"' - Netlify Support Forums)

7:52:05 AM: Finished processing build request in 36.901166292s

Hi, I’m trying to deploy the front end package that is within my monorepo to Netlify. I’m following the general recommendations laid out by Netlify, which is to include a netlify.toml file that specifies a base directory to the front end package in my monorepo. My netlify.toml looks like this:

base = “packages/frontend/”

This netlify.toml is at the root of my monorepo, and the individual packages in the monorepo all contain package.jsons that specify their own dependencies. I’m using npm workspaces to manage my monorepo.

The weird thing about this error is that when I run netlify build or netlify dev on my local machine, everything works fine. The build log seems to say that I’m doing something wrong regarding workspaces, but I can’t figure out what.

There was some strange behavior by netlify dev which might or might not be relevant. Even though I specified a base directory, netlify dev seemed to look for a “build” command in my root package.json instead of the package.json inside the front end package. I had to manually specify a npm build command in the root package.json that linked to the frontend package’s build command in order to get things working.


Hey there, @kimyoungjin1001 :wave:

Thanks so much for reaching out. Can you run this command:

npm run build || { cat /opt/buildhome/.npm/_logs/* ; sleep 30 ; false; }

To see in the log why your build is failing? This will give us more information about the error you are experiencing and how to solve it. There is more information about this in the thread I am linking below:

Additionally, here is more information from the npm docs you can implement:

Hi @hillary Hillary, thanks for the reply.
I tried replacing my old build command with the recommended one, but there aren’t any changes in the build logs I’m getting. Are there any other ways to get detailed logs?

Hey @kimyoungjin1001,

The specific error is actually here: Netlify App

We tried this and it appears to be a problem with Node and npm that you’re trying to use. We tried this on Node 18 and Node 14, and we got the exact same error locally.

So, you could try to set Netlify’s Node Version that you’ve got locally, or try to see what could be causing that error.

Hi, I’ve tried setting different node versions, but when I run the “netlify build” command there are no errors. How did you reproduce the error locally?

Hey @kimyoungjin1001

Looking at the package.json at the root of the repository and that in packages/frontend I see no build script, only a start script. This command in turn runs netlify dev which is not something you run when deploying to Netlify, it is a Netlify CLI command used when developing locally.

As explained in this post npm start won’t work on Netlify. The idea is you deploy a static site (built with something like Eleventy which I see you are using) or an SPA built with React, Vue, which is done via a build script or other build command.

Hi, thanks for your reply. I understand your concern about the netlify dev command, but doesn’t Netlify not run npm start in the first place? Meaning it doesn’t really matter what command I set for the start script.

Your comment about a missing build script did help though, but a slightly different error came up. What ultimately solved the problem was changing my node version by setting the NODE_VERSION environment variable to 16.13.2 in the Netlify UI.

Correct. As there was no build script (and there was nothing in the deploy log that showed the command you were using), I was suspecting you were running this command in Netlify (this is something people often try to do after all.)

In any event, you got it sorted so :+1:

Hi @coelmay, thanks for the reply. There’s an additional question I’d like to ask regarding the npm start command. As you agreed, Netlify doesn’t run this when I deploy my app. However, I had similar issue to this guy here, and in that thread you replied that the [dev] section needs the command variable to point to npm start. I didn’t add a command variable, but I did replace my original npm start, which ran netlify dev, with eleventy —serve, and it worked!

My question is: if Netlify doesn’t need the start command in production, how come it matters what I set the start command to when testing my app locally with netlify dev?

You don’t need to use netlify dev locally, unless you are using functions, redirects/rewrites, or other Netlify-specific service.

In essence what happens when you run netlify dev it starts your app/framework (Eleventy, React, Vue, etc.) in it’s development mode, and listens to the port it is running on (8080 with Eleventy) and makes this accessible via port 8888 (or whichever port you have configured Netlify CLI to use) along with functions which are running on another port.

Everyone does things differently (that’s what makes us human after all) so I can’t/won’t say the way you have configured NPM/Netlify is wrong or right. I don’t use NPM to start Netlify CLI (which I have installed globally, not as part of a project) I have (for example):

scripts: {
  "build": "eleventy",
  "start": "eleventy --serve"

in the package.json, then in the netlify.toml I might have

  command = "npm run build"
  publish = "_site"

  command = "npm start"

If I then wish to start the framework development server I run npm start, but if I wish to test my functions, rewrite/proxy, etc, I use netlify dev (well, ntl dev actually because it’s shorter.)

Technically that isn’t entirely correct. Netlify CLI as mentioned here automatically detects the framework used via frameworks-info so will run that command by default (here’s the eleventy info.) If you specify a command, it will run that instead.

Wow… that really clarifies a lot. No wonder using netlify dev for my npm start command crashes the whole thing. I’m making netlify dev call itself. Thanks a lot!

1 Like