[solved] Build.command failed in netlify

I tried several times to deploy the website with netlify, but it keeps failing.
Namely I get this error:

parcel build index.html
/opt/build/repo/images/logo.svg: Invalid Version: undefined

I even tried other solutions like:

At the end I tried a combination of the above.

  1. Install parcel@1.12.3 (not 1.12.4) as a dependency
    npm install -D parcel-bundler@1.12.3
    In that way you will have this:
 "devDependencies": {
    "parcel-bundler": "^1.12.3"
  }

in your package.json

1b. Also add this
"build": "parcel build index.html",
in your scripts of your package.json

  1. Install parcel-bundler@1.12.3 also globally (so later, the command parcel build index.html in netlify, will be valid).
    sudo npm -i -g parcel-bundler@1.12.3

  2. Delete the dist folder (we have double files) and run parcel build index.html again.

  3. Add node_modules and dist to .gitignore.

  4. Make a commit and push it to github.

Then follow along the instructor to deploy in netlify.

For the time being I’m not sure if all the steps above are required.
Maybe just installing parcel @1.12.3 globally would be enough.
Or maybe installing the aforementioned version as a dependency and then in netlify use npm or npx in front of the command, like npm parcel build index.html could also be enough.

Anyway happy coding!

Thanks

2 Likes

I’ve tried all your method, but still failed…No idea how is that happens.

1 Like

You can use this command and avoid the SVG/Minify problem:

parcel build index.html --no-minify

It will not include the Minify optimization but it will build and deploy.
There is an Advanced area in Netlify where you can add this as well to avoid the same error when updating and deploying on Netlify.

Hope that helps!

you can simply add a file to your project root with the name of “.htmlnanorc.js” .
then put this code in that file.

module.exports = {
  minifySvg: false,
};

after that, you can use your simple code without any flag: parcel build index.html

1 Like

Yes !
With
module.exports = {
minifySvg: false,
};
in .htmlnanorc.js saved from failing of build!
Thanks!!

1 Like

I have tried everything but nothing works

build .htmlnanorc.js:

module.exports = {
“minifySvg”: false
}

it is OK for me.