Since yesterday I'm facing an error that I haven't been able to fix or to find information about. I can build my site locally without errors but when I try to deploy it in Netlify it fails and throws:
8:19:33 AM:
8:19:33 AM: ┌─────────────────────────────┐
8:19:33 AM: │ Netlify Build │
8:19:33 AM: └─────────────────────────────┘
8:19:33 AM:
8:19:33 AM: ❯ Version
8:19:33 AM: @netlify/build 2.0.20
8:19:33 AM:
8:19:33 AM: ❯ Flags
8:19:33 AM: deployId: 5efc2a7760231502ad0a057d
8:19:33 AM: mode: buildbot
8:19:33 AM:
8:19:33 AM: ❯ Current directory
8:19:33 AM: /opt/build/repo
8:19:33 AM:
8:19:33 AM: ❯ Config file
8:19:33 AM: /opt/build/repo/netlify.toml
8:19:33 AM:
8:19:33 AM: ❯ Context
8:19:33 AM: production
8:19:33 AM:
8:19:33 AM: ┌─────────────────────────────┐
8:19:33 AM: │ Core internal error │
8:19:33 AM: └─────────────────────────────┘
8:19:33 AM:
8:19:33 AM: Error message
8:19:33 AM: Error: Invalid version: "1"
8:19:33 AM:
8:19:33 AM: Error location
8:19:33 AM: at Object.fixVersionField (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/normalize-package-data/lib/fixer.js:191:13)
8:19:33 AM: at /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/normalize-package-data/lib/normalize.js:32:38
8:19:33 AM: at Array.forEach (<anonymous>)
8:19:33 AM: at normalize (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/normalize-package-data/lib/normalize.js:31:15)
8:19:33 AM: at module.exports (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/read-pkg/index.js:20:36)
8:19:33 AM: at async module.exports (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/read-pkg-up/index.js:14:16)
8:19:33 AM: at async getPackageJson (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/utils/package.js:7:22)
8:19:33 AM: at async build (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/core/main.js:61:46)
8:19:33 AM: at async runCli (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/core/bin.js:17:29)
8:19:33 AM:
8:19:33 AM: Error properties
8:19:33 AM: { name: 'Error' }
8:19:33 AM:
8:19:33 AM: Caching artifacts
8:19:33 AM: Started saving node modules
8:19:33 AM: Finished saving node modules
8:19:33 AM: Started saving build plugins
8:19:33 AM: Finished saving build plugins
8:19:33 AM: Started saving yarn cache
8:19:33 AM: Finished saving yarn cache
8:19:33 AM: Started saving pip cache
8:19:33 AM: Finished saving pip cache
8:19:33 AM: Started saving emacs cask dependencies
8:19:33 AM: Finished saving emacs cask dependencies
8:19:33 AM: Started saving maven dependencies
8:19:33 AM: Finished saving maven dependencies
8:19:33 AM: Started saving boot dependencies
8:19:33 AM: Finished saving boot dependencies
8:19:34 AM: Started saving go dependencies
8:19:35 AM: Finished saving go dependencies
8:19:39 AM: Error running command: Build script returned non-zero exit code: 1
8:19:39 AM: Failing build: Failed to build site
8:19:39 AM: Failed during stage 'building site': Build script returned non-zero exit code: 1
8:19:39 AM: Finished processing build request in 2m10.478232047s
It seems to be related with Node versions so I tried to fix by adding a .nvmrc
but the error persists. Both (locally and Netlify) are running Node version 12.16.3
.
Of course, I also tried to build with the cache cleaned.
The issue doesn't provide much more information so I'm a bit lost.
According to https://github.com/netlify/build/issues/1608 it's a known issue that should be fixed in the next Netlify release. In the meantime, you can easily fix it by changing the version
field in package.json
from 1
to 1.0.0
:
"version": "1.0.0",
This is because, according to npm documentation:
Version must be parseable by
node-semver
, which is bundled with npm as a dependency. (npm install semver
to use it yourself.)