👀 See Sanity in action: Watch product demo now →

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.