Static site build error: Segmentation fault

I am trying to set up a static site on Render. It uses Parcel to compile the site to static files in the dist folder. The app works fine on my local machine but it fails on Render. The output looks good, it runs npm install and then my build script npm run build and logs everything I’d expect, but at the very end I see this error:

...
Oct 6 09:29:50 PM  dist/subscribed.html                                     6.55 KB    11.64s
Oct 6 09:29:50 PM  Segmentation fault
Oct 6 09:29:50 PM  npm ERR! code ELIFECYCLE
Oct 6 09:29:50 PM  npm ERR! errno 139
Oct 6 09:29:50 PM  npm ERR! site@2.1.1 build: `parcel build './src/*.html'`
Oct 6 09:29:50 PM  npm ERR! Exit status 139
Oct 6 09:29:50 PM  npm ERR!
Oct 6 09:29:50 PM  npm ERR! Failed at the site@2.1.1 build script.
Oct 6 09:29:50 PM  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Oct 6 09:29:50 PM  
Oct 6 09:29:50 PM  npm ERR! A complete log of this run can be found in:
Oct 6 09:29:50 PM  npm ERR!     /opt/render/.cache/_logs/2021-10-06T08_29_50_183Z-debug.log
Oct 6 09:29:50 PM  ==> Build failed 😞

Relevant parts of the package.json file:

{
  "scripts": {
    "start": "parcel serve './src/*.html' --open",
    "prebuild": "rm -rf ./dist",
    "build": "parcel build './src/*.html'",
    "deploy": "npm run build && node ./scripts/deploy"
  },
  "dependencies": {
    "@parcel/transformer-image": "^2.0.0-rc.0",
    "@parcel/transformer-sass": "^2.0.0-rc.0",
    "@popperjs/core": "^2.9.2",
    "bootstrap": "^5.0.1",
    "dotenv": "^7.0.0",
    "ftp-deploy": "^2.4.1",
    "parcel": "^2.0.0-rc.0",
    "parcel-plugin-nuke-dist": "^1.0.1",
    "parcel-reporter-static-files-copy": "^1.3.0",
    "posthtml-doctype": "^1.1.1",
    "posthtml-include": "^1.7.1"
  }
}

Has anyone else seen this type of error or know how to resolve it?

Well, I managed to solve this as soon as I had posted the question above!

It turns out there is a know issue with the latest version of Parcel and certain environments, related to PARCEL_WORKERS. There are a couple of workarounds discussed here.

For me, adding the following environment variable did the trick:

PARCEL_WORKER_BACKEND = process