Netlify Build fails after adding jQuery and parseHTML

I added jQuery to accomplish a hacky way of allowing <br> tags in a text box (using $.parseHTML & NetlifyCMS). Everything works locally with no console errors, but when I push to GitHub to auto-deploy, it fails to build due to the error below. Any help would be greatly appreciated. I am also using Gatsby if that matters.

jQuery is imported in the file and is included in the package.json.

Site: ballisticagency-dev.netlify.app

Build Logs: https://paste.ofcode.org/xjR2hvATB3WUfAnVfDq8sv

Hey @BallisticAgency

Curious why you need/want to do this?

The easy answer is to not implement hacky methods to accomplish a task.

Looking at the error, the build is trying to run jQuery when (I assume) you only want this to run in the browser. If you want to run jQuery in node there is a method outlined on the npm package page.

You’re absolutely correct. The easy answer would be to not implement hacky methods, but it is what it is and not an actual answer to the issue.

The original goal was to be able to parse markdown from frontmatter – this is mainly due to the fact that I was using fields with text widgets previously to do sections of copy for the site, but it doesn’t allow “\n” or “
” since it outputs as a plain string.

The build runs jQuery as a part of a component when it’s trying to generate the static page (this is my assumption, but may not be 100% correct). Since this is doing this pre-build stage, it isn’t just in the browser, correct?

The component has a graphQL query that generates whitepaper which has fields such as copy & heading. However, I am wanting to parse whitepaper.copy so that I can take allow for the <br> tags in the copy section. Below is exactly the code that is used to do so for whitepaper and emaillatest.

var whitepaperCopy = $.parseHTML(whitepaper.copy)
var emailCopy = $.parseHTML(emaillatest.copy)

Hey @BallisticAgency,

Could you share a reproduction of any kind?