Build error in Remix app with Prisma seed file

Netlify site name: platypus-schoolhouse

I added Prisma to my previously deployed Remix project and when I pushed it to a remote branch and Netlify picked up the changes and built it, I got the build error shown below. It doesn’t say it’s a problem in the seed file, but the log includes the first two lines of the seed file so that’s what I’m suspecting. Originally I was using a TypeScript seed file, and I switched it to a JavaScript file, just to rule out problems with ts-node - but the error was the same.

Build Log:
12:57:58 PM: Build ready to start

12:58:00 PM: build-image version: 6ebfb829398e07eb99ad5455777162ff19838822 (xenial)

12:58:00 PM: build-image tag: v3.10.5

12:58:00 PM: buildbot version: d0df77beca2ca61b1d04bd8011a622c1b1302d7c

12:58:00 PM: Building without cache

12:58:00 PM: Starting to prepare the repo for build

12:58:00 PM: Git LFS enabled

12:58:01 PM: No cached dependencies found. Cloning fresh repo

12:58:01 PM: git lfs clone git@gitlab.com:platypus-schoolhouse/pp-monorepo

12:58:01 PM: using git lfs fetchinclude override of: *.jpg,*.png,*.jpeg,*.svg,*.gif,*.pdf,*.mp4,*.bmp,*.tif,*.tiff,*.bin

12:58:07 PM: Preparing Git Reference refs/heads/auth-etc

12:58:08 PM: using git lfs fetchinclude override of: *.jpg,*.png,*.jpeg,*.svg,*.gif,*.pdf,*.mp4,*.bmp,*.tif,*.tiff,*.bin

12:58:08 PM: Parsing package.json dependencies

12:58:09 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'platypus-schoolhouse/public' versus 'dist' in the Netlify UI

12:58:09 PM: Different functions path detected, going to use the one specified in the Netlify configuration file: 'platypus-schoolhouse/netlify/functions' versus '' in the Netlify UI

12:58:09 PM: Different build command detected, going to use the one specified in the Netlify configuration file: 'tailwindcss -o ./app/styles/tailwind.css && remix build' versus 'npm run export' in the Netlify UI

12:58:09 PM: Starting build script

12:58:09 PM: Installing dependencies

12:58:09 PM: Python version set to 2.7

12:58:10 PM: v12.18.0 is already installed.

12:58:11 PM: Now using node v12.18.0 (npm v6.14.4)

12:58:11 PM: Started restoring cached build plugins

12:58:11 PM: Finished restoring cached build plugins

12:58:11 PM: Attempting ruby version 2.7.2, read from environment

12:58:13 PM: Using ruby version 2.7.2

12:58:13 PM: Using PHP version 5.6

12:58:13 PM: Started restoring cached node modules

12:58:13 PM: Finished restoring cached node modules

12:58:13 PM: Installing NPM modules using NPM version 6.14.4

12:58:40 PM: npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!

12:58:40 PM: > prisma@3.10.0 preinstall /opt/build/repo/platypus-schoolhouse/node_modules/prisma

12:58:40 PM: > node scripts/preinstall-entry.js

12:58:42 PM: > deasync@0.1.24 install /opt/build/repo/platypus-schoolhouse/node_modules/deasync

12:58:42 PM: > node ./build.js

12:58:42 PM: `linux-x64-node-12` exists; testing

12:58:42 PM: Binary is fine; exiting

12:58:42 PM: > prisma@3.10.0 install /opt/build/repo/platypus-schoolhouse/node_modules/prisma

12:58:42 PM: > node scripts/install-entry.js

12:58:42 PM: > re2@1.17.4 install /opt/build/repo/platypus-schoolhouse/node_modules/re2

12:58:42 PM: > install-from-cache --artifact build/Release/re2.node --host-var RE2_DOWNLOAD_MIRROR --skip-path-var RE2_DOWNLOAD_SKIP_PATH --skip-ver-var RE2_DOWNLOAD_SKIP_VER || npm run rebuild

12:58:43 PM: Trying https://github.com/uhop/node-re2/releases/download/1.17.4/linux-x64-72.br ...

12:58:43 PM: Writing to build/Release/re2.node ...

12:58:44 PM: Done.

12:58:44 PM: > @prisma/engines@3.10.0-50.73e60b76d394f8d37d8ebd1f8918c79029f0db86 postinstall /opt/build/repo/platypus-schoolhouse/node_modules/@prisma/engines

12:58:44 PM: > node download/index.js

12:58:46 PM: > esbuild@0.14.22 postinstall /opt/build/repo/platypus-schoolhouse/node_modules/@remix-run/dev/node_modules/esbuild

12:58:46 PM: > node install.js

12:58:47 PM: > @prisma/client@3.10.0 postinstall /opt/build/repo/platypus-schoolhouse/node_modules/@prisma/client

12:58:47 PM: > node scripts/postinstall.js

12:58:49 PM: Prisma schema loaded from prisma/schema.prisma

12:58:52 PM: ✔ Generated Prisma Client (3.10.0 | library) to ./node_modules/@prisma/client in 226ms

12:58:52 PM: You can now start using Prisma Client in your code. Reference: https://pris.ly/d/client

12:58:52 PM: ```
import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()

12:58:53 PM: > esbuild@0.14.23 postinstall /opt/build/repo/platypus-schoolhouse/node_modules/esbuild

12:58:53 PM: > node install.js

12:58:53 PM: > remix-app-template@ postinstall /opt/build/repo/platypus-schoolhouse

12:58:53 PM: > remix setup node && metronome setup

12:58:53 PM: internal/modules/cjs/loader.js:969

12:58:53 PM: throw err;

12:58:53 PM: ^

12:58:53 PM: Error: Cannot find module ‘fs/promises’

12:58:53 PM: Require stack:

12:58:53 PM: - /opt/build/repo/platypus-schoolhouse/node_modules/@remix-run/dev/compiler/plugins/serverRouteModulesPlugin.js

12:58:53 PM: - /opt/build/repo/platypus-schoolhouse/node_modules/@remix-run/dev/compiler.js

12:58:53 PM: - /opt/build/repo/platypus-schoolhouse/node_modules/@remix-run/dev/cli/commands.js

12:58:53 PM: - /opt/build/repo/platypus-schoolhouse/node_modules/@remix-run/dev/cli.js

12:58:53 PM: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)

12:58:53 PM: at Function.Module._load (internal/modules/cjs/loader.js:842:27)

12:58:53 PM: at Module.require (internal/modules/cjs/loader.js:1026:19)

12:58:53 PM: at require (internal/modules/cjs/helpers.js:72:18)

12:58:53 PM: at Object. (/opt/build/repo/platypus-schoolhouse/node_modules/@remix-run/dev/compiler/plugins/serverRouteModulesPlugin.js:16:11)

12:58:53 PM: at Module._compile (internal/modules/cjs/loader.js:1138:30)

12:58:53 PM: at Object.Module._extensions…js (internal/modules/cjs/loader.js:1158:10)

12:58:53 PM: at Module.load (internal/modules/cjs/loader.js:986:32)

12:58:53 PM: at Function.Module._load (internal/modules/cjs/loader.js:879:14)

12:58:53 PM: at Module.require (internal/modules/cjs/loader.js:1026:19) {

12:58:53 PM: code: ‘MODULE_NOT_FOUND’,

12:58:53 PM: requireStack: [

12:58:53 PM: ‘/opt/build/repo/platypus-schoolhouse/node_modules/@remix-run/dev/compiler/plugins/serverRouteModulesPlugin.js’,

12:58:53 PM: ‘/opt/build/repo/platypus-schoolhouse/node_modules/@remix-run/dev/compiler.js’,

12:58:53 PM: ‘/opt/build/repo/platypus-schoolhouse/node_modules/@remix-run/dev/cli/commands.js’,

12:58:53 PM: ‘/opt/build/repo/platypus-schoolhouse/node_modules/@remix-run/dev/cli.js’

12:58:53 PM: ]

12:58:53 PM: }

12:58:53 PM: npm ERR! code ELIFECYCLE

12:58:53 PM: npm ERR! errno 1

12:58:53 PM: npm ERR! remix-app-template@ postinstall: remix setup node && metronome setup

12:58:53 PM: npm ERR! Exit status 1

12:58:53 PM: npm ERR!

12:58:53 PM: npm ERR! Failed at the remix-app-template@ postinstall script.

12:58:53 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

12:58:54 PM: npm ERR! A complete log of this run can be found in:

12:58:54 PM: npm ERR! /opt/buildhome/.npm/_logs/2022-02-26T19_58_53_980Z-debug.log

12:58:54 PM: Error during NPM install

12:58:54 PM: Build was terminated: Build script returned non-zero exit code: 1

12:58:54 PM: Creating deploy upload records

12:58:54 PM: Failing build: Failed to build site

12:58:54 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 1

12:58:54 PM: Finished processing build request in 53.579019497s

Actually, upon further reflection, I don’t think the Prisma seed file is causing this, since it is not supposed to even run in a production scenario - rather it is the Prisma migration code that is likely using the fs library to read the migration files. I found an issue on the Remix Github account for a similar problem when deploying a Prisma project in a monorepo (which I also have) to Vercel. It seemed to have something to do with Vercel’s Functions-as-a-Service not supporting the fs library. Could that be the case here as well?

Hey @jbstewart

Does this build correctly when you do it locally?

I am wondering if it is, in part at least, because the build is using node v12

Does changing the node version (see documentation) to v14, or v16 eliminate the issue?

Yes it does build correctly locally. I thought I was running node 14 locally, but I just checked and it’s actually v16.13.2. Does Netlify default to Node 12? Where do I change that? I have AWS_LAMBDA_JS_RUNTIME set to nodejs14.x but that only applies to functions, right?

@coelmay That fixed it. Nice catch. Thanks!

PS Use .nvmrc if anyone else is wondering how to set the node version for Netlify.

In the latest build image v16 is the default. In the older v3 build image as your build is using, the default was v12.

1 Like