Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parcel JS: tree.render is not a function

Whenever I try to run production build command npm run build or npx parcel build index.html, I get this error. I have a simple html and css project, no react, no 3rd party library Why could this be happening? I have tried parcel versions 1.12.3, 1.12.4 and 1.12.5.

Here is the error:

/Users/user/Documents/HTML Apps/Project/index.html: tree.render is not a function
at /Users/user/Documents/HTML Apps/Project/node_modules/htmlnano/lib/modules/minifySvg.js:19:23
at /Users/user/Documents/HTML Apps/Project/node_modules/posthtml/lib/api.js:91:45
at traverse (/Users/user/Documents/HTML Apps/Project/node_modules/posthtml/lib/api.js:105:26)
at traverse (/Users/user/Documents/HTML Apps/Project/node_modules/posthtml/lib/api.js:111:5)
at traverse (/Users/user/Documents/HTML Apps/Project/node_modules/posthtml/lib/api.js:105:17)
at traverse (/Users/user/Documents/HTML Apps/Project/node_modules/posthtml/lib/api.js:111:5)
at traverse (/Users/user/user/HTML Apps/Project/node_modules/posthtml/lib/api.js:105:17)
at traverse (/Users/user/Documents/HTML Apps/Project/node_modules/posthtml/lib/api.js:111:5)
at traverse (/Users/user/Documents/HTML Apps/Project/node_modules/posthtml/lib/api.js:105:17)
at traverse (/Users/user/Documents/HTML Apps/Project/node_modules/posthtml/lib/api.js:111:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `parcel build index.html`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/user/.npm/_logs/2021-04-14T07_44_52_872Z-debug.log
like image 516
Karanveer Singh Avatar asked Apr 14 '21 07:04

Karanveer Singh


People also ask

What types of JavaScript does parcel support?

In addition to standard JavaScript, Parcel automatically handles JSX, TypeScript, and Flow, along with Node.js features like process.env and fs.readFileSync – no configuration needed! And if you need more advanced control, or support for custom transforms, just add a .babelrc or .postcssrc and it'll be picked up automatically.

Is parcel-bundler deprecated?

Problem solved: parcel-bundler is deprecated. Use 'parcel' not 'parcel-bundler' Show activity on this post. package.json If you have preset the scripts... Replace index.html to whatever file you want to build, but make sure it is the same type of file. Thanks for contributing an answer to Stack Overflow! Please be sure to answer the question.

What happens when I make an error in parcel?

If you make an error in your code or configuration, Parcel displays beautiful diagnostics in your terminal and in the browser. Every error includes a syntax highlighted code frame pointing to the exact location where the error occurred, along with hints about how to fix the issue.

What is parcel's Dev Server?

This means the dev server restarts instantly, and the same code is never built twice. Parcel automatically tracks all of the files, configuration, plugins, and dev dependencies that are involved in your build, and granularly invalidates the cache when something changes.


1 Answers

Turns out you can get around this by configuring htmlnano to not minify SVG.

Add a .htmlnanorc file to your project root, with a JSON configuration object like this:

{
    "minifySvg": false
}

The relevant part of the documentation is here for V1 (which actually doesn't mention the minifySvg setting) or here for V2.

like image 186
sepiariver Avatar answered Sep 26 '22 05:09

sepiariver