Build failing for Gatsby Next pages due to missing dependencies
5 replies
Last updated: Jun 3, 2020
L
Hey π I'm having issues with the build failing for both my studio and front end for the gatsby next pages. I'm getting the following error in the Netlify output..
12:14:42 PM: > next build && next export && node exportSitemap.js 12:14:42 PM: lerna 12:14:42 PM: ERR! 12:14:42 PM: npm run build 12:14:42 PM: stderr: 12:14:42 PM: sh: 1: next: not found 12:14:42 PM: npm ERR! code ELIFECYCLE 12:14:42 PM: npm ERR! syscall spawn 12:14:42 PM: npm ERR! file sh 12:14:42 PM: npm ERR! errno ENOENT 12:14:42 PM: npm ERR! sanity-nextjs-landing-pages-web@1.0.5 build: `next build && next export && node exportSitemap.js` 12:14:42 PM: npm ERR! spawn ENOENT 12:14:42 PM: npm ERR! 12:14:42 PM: npm ERR! Failed at the sanity-nextjs-landing-pages-web@1.0.5 build script. 12:14:42 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above. 12:14:42 PM: npm WARN Local package.json exists, but node_modules missing, did you mean to install? 12:14:42 PM: npm ERR! A complete log of this run can be found in: 12:14:42 PM: npm ERR! /opt/buildhome/.npm/_logs/2020-06-01T11_14_42_427Z-debug.log 12:14:42 PM: lerna 12:14:42 PM: ERR! 12:14:42 PM: npm run build 12:14:42 PM: exited 1 in 'sanity-nextjs-landing-pages-web' 12:14:42 PM: lerna 12:14:42 PM: WARN 12:14:42 PM: complete 12:14:42 PM: Waiting for 1 child process to exit. CTRL-C to exit immediately. 12:14:42 PM: npm ERR! code ELIFECYCLE 12:14:42 PM: npm ERR! errno 1 12:14:42 PM: npm ERR! sanity-nextjs-landing-pages@1.0.5 build: `lerna run build --parallel` 12:14:42 PM: npm ERR! Exit status 1 12:14:42 PM: npm ERR! 12:14:42 PM: npm ERR! Failed at the sanity-nextjs-landing-pages@1.0.5 build script. 12:14:42 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above. 12:14:42 PM: npm 12:14:42 PM: ERR! 12:14:42 PM: A complete log of this run can be found in: 12:14:42 PM: npm 12:14:42 PM: ERR! 12:14:42 PM: /opt/buildhome/.npm/_logs/2020-06-01T11_14_42_471Z-debug.log 12:14:42 PM: 12:14:42 PM: βββββββββββββββββββββββββββββββ 12:14:42 PM: β "build.command" failed β 12:14:42 PM: βββββββββββββββββββββββββββββββ 12:14:42 PM: 12:14:42 PM: Error message 12:14:42 PM: Command failed with exit code 1: npm run build 12:14:42 PM: 12:14:42 PM: Error location 12:14:42 PM: In Build command from settings: 12:14:42 PM: npm run build 12:14:42 PM: 12:14:42 PM: Resolved config 12:14:42 PM: build: 12:14:42 PM: base: /opt/build/repo 12:14:42 PM: command: npm run build 12:14:42 PM: publish: /opt/build/repo/web/out 12:14:42 PM: Caching artifacts 12:14:42 PM: Started saving node modules 12:14:42 PM: Finished saving node modules 12:14:42 PM: Started saving build plugins 12:14:42 PM: Finished saving build plugins 12:14:42 PM: Started saving pip cache 12:14:43 PM: Finished saving pip cache 12:14:43 PM: Started saving emacs cask dependencies 12:14:43 PM: Finished saving emacs cask dependencies 12:14:43 PM: Started saving maven dependencies 12:14:43 PM: Finished saving maven dependencies 12:14:43 PM: Started saving boot dependencies 12:14:43 PM: Finished saving boot dependencies 12:14:43 PM: Started saving go dependencies 12:14:43 PM: Finished saving go dependencies 12:14:43 PM: Error running command: Build script returned non-zero exit code: 1 12:14:43 PM: Failing build: Failed to build site 12:14:43 PM: Failed during stage 'building site': Build script returned non-zero exit code: 1 12:14:43 PM: Finished processing build request in 17.856230569s
Jun 1, 2020, 11:16 AM
C
had the same problem last night deleted the node_modules folder and yarn.lock installed again and the deployment went through.
Jun 1, 2020, 11:33 PM
P
Are you still seeing this issue? Like Carlos said, removing `package-lock.json`/`yarn.lock.json`, as well as the
node_modulesfolder (if they exist) before running
npm installshould resolve the issue.
Jun 2, 2020, 4:53 PM
L
I did try that but will give it another go and fingers crossed!
Jun 3, 2020, 1:03 PM
L
Third time lucky π thanks both!
Jun 3, 2020, 4:32 PM
P
Awesome, glad to hear!
Jun 3, 2020, 4:40 PM
Sanityβ build remarkable experiences at scale
The Sanity Composable Content Cloud is the headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.