When your SPA site suddenly cannot be built on Netlify, how to fix?

lockevn
1 min readSep 12, 2021

Netlify suddenly cannot build my site (fully SPA with VueJs) 2 days ago (with the same codebase) and I cannot figure out why.

Assumption on your Netlify Deploy config

  • Netlify consumes GitHub repo to build the site
  • Go to your site / Deploys/ Build settings / Publish directory = dist)

Correct fix: continue to build on CI (Netlify)

  • Move the entire thing in your package.json, from devDependencies to dependencies
  • WHY? most CI processes (include Netlify build) will set the NODE_ENV to production and npm will skip devDependencies with that variable set.

Dirty quick fix: build on local

  • prebuild your SPA site to /dist on local machine
  • include (modify your .gitignore) and push the /dist folder to GitHub repo (then Netlify will take everything from that repo to create your site)
  • Do not set build command on Netlify (Go to your site / Deploys/ Build settings / Build command = empty)

It’s not a Netlify issue as such. Most CI processes will set the NODE_ENVto “production” and NPM will skip devDependencieswith that variable set. The strange part is that, I’ve not seen this happen always. While it’s not always the case, the packages within devDependenciesmight not be installed sometimes.

PS: here is detail thread of mine to solve this problem with great help from Netlify

PSS: Netlify rocks!

--

--

lockevn

Developer, Sportman. Write code with joy, bake app with heart. Opinions are my own. If you feel I save your time, go http://BuyMeACoff.ee/Lockevn