Watch a live product demo 👀 See how Sanity powers richer commerce experiences

Next.js Github Build Error - sanity-nextjs-landing-pages-web: npm ERR!

10 replies
Last updated: Aug 24, 2020
I’m having an issue with the build process. Every time an automated build kicks off from a Github push, the build fails. However if I restart/retry the deply with the cache cleared it builds / deploys successfully. EVERY SINGLE TIME.
11
:16:05 AM: sanity-nextjs-landing-pages-studio: > sanity-nextjs-landing-pages-studio@1.0.4 build /opt/build/repo/studio11
:16:05 AM: sanity-nextjs-landing-pages-studio: > sanity build11
:16:05 AM: sanity-nextjs-landing-pages-web: > sanity-nextjs-landing-pages-web@1.0.7 build /opt/build/repo/web11
:16:05 AM: sanity-nextjs-landing-pages-web: > next build && next export && node exportSitemap.js11
:16:05 AM: sanity-nextjs-landing-pages-web: sh: 1: next: not found11
:16:05 AM: sanity-nextjs-landing-pages-web: npm ERR! code ELIFECYCLE11
:16:05 AM: sanity-nextjs-landing-pages-web: npm ERR! syscall spawn11
:16:05 AM: sanity-nextjs-landing-pages-web: npm ERR! file sh11
:16:05 AM: sanity-nextjs-landing-pages-web: npm ERR! errno ENOENT11
:16:05 AM: sanity-nextjs-landing-pages-web: npm ERR! sanity-nextjs-landing-pages-web@1.0.7 build:
next build && next export && node exportSitemap.js
11
:16:05 AM: sanity-nextjs-landing-pages-web: npm ERR! spawn ENOENT11
:16:05 AM: sanity-nextjs-landing-pages-web: npm ERR!11
:16:05 AM: sanity-nextjs-landing-pages-web: npm ERR! Failed at the sanity-nextjs-landing-pages-web@1.0.7 build script.11
:16:05 AM: sanity-nextjs-landing-pages-web: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.11
:16:05 AM: sanity-nextjs-landing-pages-web: npm WARN Local package.json exists, but node_modules missing, did you mean to install?11
:16:05 AM: sanity-nextjs-landing-pages-web: npm ERR! A complete log of this run can be found in:11
:16:05 AM: sanity-nextjs-landing-pages-web: npm ERR! /opt/buildhome/.npm/_logs/2020-08-24T04_16_05_419Z-debug.log
Aug 24, 2020, 4:20 AM
Is next.js CLI included in your devDependencies and do you run install and/or cache node_modules before running.
Aug 24, 2020, 6:35 AM
I’m only saying because it’s clearly saying that it can’t find the command
next
.
Aug 24, 2020, 6:35 AM
oh doesn’t look like it. Here is my package.json
Aug 24, 2020, 6:37 AM
{
  "private": true,
  "name": "sanity-nextjs-landing-pages",
  "version": "1.0.7",
  "scripts": {
    "build": "lerna run build --parallel",
    "build-web": "lerna bootstrap && (cd web && npm run build)",
    "build-studio": "lerna bootstrap && (cd studio && npm run build)",
    "dev": "lerna run dev --parallel",
    "format": "lerna run format",
    "graphql-deploy": "lerna run graphql-deploy",
    "lint": "lerna run lint",
    "postinstall": "lerna bootstrap",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "devDependencies": {
    "@sanity/cli": "^1.149.19",
    "lerna": "^3.9.0"
  },
  "dependencies": {
    "@zeit/next-sass": "^1.0.1",
    "bootstrap": "^4.5.2",
    "node-sass": "^4.14.1",
    "react-bootstrap": "^1.3.0",
    "sass": "^1.26.10"
  }
}

Aug 24, 2020, 6:37 AM
yes that might help. Though I’m surprised it works with a clean cache if that’s the case.
Aug 24, 2020, 6:38 AM
yeah, I thought it would be part of the starter project
Aug 24, 2020, 6:38 AM
I think they rely on the CLI tool being installed globally for your machine don’t they? It’s been a while since I used next.
Aug 24, 2020, 6:40 AM
yeah it is installed on my machine and works fine locally, it’s the deploy to netify that didn’t work
Aug 24, 2020, 6:44 AM
but looks like adding next.js to my package.json solved it. I owe you a beer!
Aug 24, 2020, 6:44 AM
No worries! Have a good one 👍
Aug 24, 2020, 6:44 AM

Sanity.io – build remarkable experiences at scale

Sanity is a customizable solution that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Related answers

Get more help in the community Slack

TopicCategoriesFeaturedRepliesLast Updated
After adding the subtitle and running this code npm run graphql-deploy It does nothingSep 15, 2020
how to limit a reference to just one entry in Studio reference input side versus the default as-many-entries-as-you-fill-in-an-array...Sep 18, 2020
Is it possible to fetch more than one "_type" using GROQ?Nov 2, 2020
I want to add a view with the Structure builder (S.view.component) where I list similar documents based on the title. What...Sep 23, 2020
Is there a structure builder example where the format of each preview for the document list is modified?Feb 3, 2021
I have an array of references to a country schema type but it always just returns NULL values for meJan 30, 2021
Hi, I need help with a query for getting the url of an image asset. Here is what I've been trying, but I only get the _ref...Dec 1, 2020
Sanity UI looks brilliant :smiley: Is something like the current date picker possible at the moment? I’m not sure if anicon...Dec 21, 2020
Hey everyone. I have been coding and may have potentially accidentally deleted something. Does anyone know how to resolve...Dec 26, 2020
Hello everyone and happy new year :raised_hands::skin-tone-2:, I have a problem with outputting Portable Text :disappointed:...Jan 1, 2021

Related contributions

Clean Next.js + Sanity app
- Template

Official(made by Sanity team)

A clean example of Next.js with embedded Sanity ready for recomposition.

Cody Olsen
Go to Clean Next.js + Sanity app

Blog with Built-in Content Editing
- Template

Official(made by Sanity team)

A Sanity-powered blog with built-in content editing and instant previews.

Go to Blog with Built-in Content Editing