question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Deploy to Netlify failing

See original GitHub issue

Description

Was wondering if anyone has this issue? Cannot deploy Gatsby blog on netlify as of recently. Gatsby build and develop works perfectly fine on local.

Steps to reproduce

Build and deploy on netlify. Repo: https://github.com/seanngpack/Seans-Portfolio

How to Make a Minimal Reproduction: https://www.gatsbyjs.org/contributing/how-to-make-a-reproducible-test-case/

Expected result

Netlify error seems to be related to Gatsby-cli. Here is a snippet of the build log from Netlify. This is the only error logged and it starts when Netlify calls gatsby build


Executing user command: gatsby build
11:52:38 AM: /opt/build/repo/node_modules/gatsby/node_modules/gatsby-cli/lib/init-starter.js:117
11:52:38 AM:   } catch {
11:52:38 AM:           ^
11:52:38 AM: SyntaxError: Unexpected token {
11:52:38 AM:     at createScript (vm.js:80:10)
11:52:38 AM:     at Object.runInThisContext (vm.js:139:10)
11:52:38 AM:     at Module._compile (module.js:617:28)
11:52:38 AM:     at Object.Module._extensions..js (module.js:664:10)
11:52:38 AM:     at Module.load (module.js:566:32)
11:52:38 AM:     at tryModuleLoad (module.js:506:12)
11:52:38 AM:     at Function.Module._load (module.js:498:3)
11:52:38 AM:     at Module.require (module.js:597:17)
11:52:38 AM:     at require (internal/module.js:11:18)
11:52:38 AM:     at Object.<anonymous> (/opt/build/repo/node_modules/gatsby/node_modules/gatsby-cli/lib/create-cli.js:28:20)
11:52:38 AM: Skipping functions preparation step: no functions directory set

Environment

click to expand

System: OS: macOS 10.15.4 CPU: (12) x64 Intel® Core™ i7-9750H CPU @ 2.60GHz Shell: 5.7.1 - /bin/zsh Binaries: Node: 14.3.0 - /usr/local/bin/node npm: 6.14.5 - /usr/local/bin/npm Languages: Python: 3.7.7 - /usr/local/opt/python/libexec/bin/python Browsers: Chrome: 81.0.4044.138 Safari: 13.1 npmPackages: gatsby: ^2.22.9 => 2.22.9 gatsby-image: ^2.2.33 => 2.4.5 gatsby-plugin-feed: ^2.3.21 => 2.5.3 gatsby-plugin-google-analytics: ^2.1.28 => 2.3.2 gatsby-plugin-manifest: ^2.2.29 => 2.4.9 gatsby-plugin-react-helmet: ^3.1.15 => 3.3.2 gatsby-plugin-remove-serviceworker: ^1.0.0 => 1.0.0 gatsby-plugin-sharp: ^2.3.2 => 2.6.9 gatsby-plugin-typography: ^2.3.17 => 2.5.2 gatsby-remark-copy-linked-files: ^2.1.30 => 2.3.3 gatsby-remark-embed-video: ^2.0.1 => 2.0.1 gatsby-remark-images: ^3.1.33 => 3.3.8 gatsby-remark-prismjs: ^3.3.24 => 3.5.2 gatsby-remark-responsive-iframe: ^2.2.27 => 2.4.3 gatsby-remark-smartypants: ^2.1.16 => 2.3.2 gatsby-source-filesystem: ^2.1.38 => 2.3.8 gatsby-transformer-remark: ^2.6.37 => 2.8.13 gatsby-transformer-sharp: ^2.3.5 => 2.5.3 npmGlobalPackages: gatsby-cli: 2.12.34

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

14reactions
andelhcommented, May 24, 2020

Hey @seanngpack, I was running into the exact same issue and I ended up fixing it by setting a higher Node.js version in Netlify. My Netlify build was defaulting to v8.17.0 when Gatsby needs v10.13.0 or higher.

I committed a .nvmrc file with the version matching what I was using locally and everything built and deployed fine. There are some other ways to set the Node version documented here.

Hope this helps!

Thank you this worked for me! For me it was as simple as setting an environment variable in Netlify like so:

NODE_VERSION 10

Screen Shot 2020-05-24 at 2 27 26 PM
10reactions
lpatino10commented, May 24, 2020

Hey @seanngpack, I was running into the exact same issue and I ended up fixing it by setting a higher Node.js version in Netlify. My Netlify build was defaulting to v8.17.0 when Gatsby needs v10.13.0 or higher.

I committed a .nvmrc file with the version matching what I was using locally and everything built and deployed fine. There are some other ways to set the Node version documented here.

Hope this helps!

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Support Guide] Frequently encountered problems during builds
If a build fails, it's worth retrying with a cleared build cache to see if this works better. You can do this by...
Read more >
Deploy failed Netlify - Stack Overflow
A workaround is removing /build from your .gitignore and then removing the build command (yarn build or npm run build) from the build...
Read more >
2 ways to overcome deployment problems with React on Netlify
Problems I faced in two of my projects · Solution 1: Change the build part of the script in the package.json file in...
Read more >
Netlify Deployment fails - Show & Tell - RedwoodJS Community
I'd also suggest trying to clear the cache when triggering a Netlify build. Maybe there are some artifacts from prior builds to clean...
Read more >
How to Deploy a React Router App to Netlify and Fix the ...
In this article, you will learn how to deploy a React application that uses react-router without any problems. The Problem with Deploying react- ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found