How to use Redwood with Node v14

Issue

You may have encountered segmentation faults (SIGSEGV error) when trying out Redwood on a Node v14 setup. The yarn rw dev command would typically fail on the Prisma client generation:

Command failed with exit code 139: yarn prisma generate
Segmentation fault (core dumped)
error Command failed with exit code 139.

Cause

Apparently the bug is with Node itself, which is not able to handle Prisma’s concurrent file writes.
See issue #2361:

Solution

The Prisma team has deactivated concurrent file writes for Node 14 until they can figure out a proper resolution with Node’s team.

Until that fix makes it to a release and into a Redwood release as well, it seems there are two solutions for us:

1. For the patient one

Switch back to Node v12/v13 and wait :upside_down_face:

2. If you really want Node v14

Since the segmentation fault happens in the code that downloads Prisma’s binaries, I found this workaround to work locally:

# Move to the api/prisma directory
$ cd /path/to/rw/project/api/prisma

# Call prisma generate from the current alpha to download the binary with v14-aware code
# Adapt the values for BINARY_TARGET and DATABASE_URL to your own environment
$ BINARY_TARGET=native DATABASE_URL=file:./dev.db npx @prisma/cli@alpha generate

# Back to the project dir, you should be able to use `yarn rw dev`
$ yarn rw dev

Strangely, the call to prisma generate did output a segmentation fault message, but things did work afterwards.

Hopefully this can help those who want/need to run on Node v14, until things settle down :slight_smile:

3 Likes