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.

When does netlify build run locally and in the remote CI context?

See original GitHub issue

The docs mention:

Like Netlify dev, Netlify build runs locally and in the remote CI context

Can more information be provided about how to know where the build actually happens and whether that’s something that can be controlled?

Also, how does it work in relation to netlify deploy? Does netlify deploy run another build?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ehmickycommented, Feb 26, 2020

We are trying to make local builds as similar as possible with production CI builds. This is a work in progress though and we don’t have a precise list of the small differences between both environments at the moment unfortunately.

If this issue is about https://github.com/netlify/zip-it-and-ship-it/issues/81, please feel free to add more context to that issue directly. Are you using the new Netlify Build beta in production as well, or only through the CLI?

1reaction
ehmickycommented, Feb 26, 2020

Hi @2color, thanks for reaching out!

There are three ways to trigger a Netlify Build:

  1. @netlify/build runs a Netlify build programmatically. You can require it from Node.js and call it as a normal async function.
  2. Netlify CLI has a netlify deploy command which runs @netlify/build under the hood.
  3. The Netlify production CI uses @netlify/build to run deployments.

Builds with 1. and 2. happen locally (e.g. on your machine) whereas 3. happens inside Netlify production CI.

If you are building a Build plugin, the best way to detect this is to use the IS_LOCAL constant. If you are simply running shell commands (e.g. inside build.command or build.lifecycle), the best way to detect this is to check whether the NETLIFY environment variable is true.

Let me know if that solves your problem!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Get started with Netlify CLI
Run builds locally​​ The command will build your project using environment variables set in netlify. toml and those set using the Netlify UI,...
Read more >
Netlify Build
Netlify Build is modern CI/CD infrastructure for frontend teams, pre-configured and fully automated so you can focus on writing code that moves your...
Read more >
Build configuration overview - Netlify Docs
Reference basic build settings for a repository using continuous deployment, and understand build image options for your site.
Read more >
Build functions - Netlify Docs
Create functions source files in TypeScript, JavaScript, and Go. Use environment variables with functions, manage dependencies, and test locally.
Read more >
[Support Guide] Debugging Netlify site builds
Some background. There are a fair number of reasons that a build could fail in Netlify's CI environment, even if building works locally....
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