When your SPA site suddenly cannot be built on Netlify, how to fix?
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
, fromdevDependencies
todependencies
- WHY? most CI processes (include Netlify build) will set the
NODE_ENV
toproduction
andnpm
will skipdevDependencies
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_ENV
to “production” and NPM will skip devDependencies
with 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 devDependencies
might not be installed sometimes.
PS: here is detail thread of mine to solve this problem with great help from Netlify
PSS: Netlify rocks!