Postinstall scripts are not being run(solved)

I'm trying to get my server up and running, but the process is everything but transparent. My server uses Prisma (an ORM), which requires some extra files after the package (@prisma/client) is installed.
For some reason, the built-in postinstall from the package is not being run. When I specifically include a postinstall script, it doesn't get run either, perhaps because you guys merge my package.json with some prebuilt for Arena, but your postinstall takes precedence?

This is the log from the server

579bf4f559-bknmd | 2022-04-05T03:24:39.598404836Z 'arena.secret.env' does not exist.
579bf4f559-bknmd | 2022-04-05T03:24:39.598430906Z Check / Merge Override Package JSON
579bf4f559-bknmd | 2022-04-05T03:24:39.697223856Z Found new package json to merge
579bf4f559-bknmd | 2022-04-05T03:24:39.701266084Z Adding Dependencies
579bf4f559-bknmd | 2022-04-05T03:24:39.702699653Z {
579bf4f559-bknmd | 2022-04-05T03:24:39.702706553Z   '@colyseus/arena': '^0.14.24',
579bf4f559-bknmd | 2022-04-05T03:24:39.702709003Z   '@colyseus/core': '^0.14.28',
579bf4f559-bknmd | 2022-04-05T03:24:39.702711082Z   '@colyseus/monitor': '^0.14.22',
579bf4f559-bknmd | 2022-04-05T03:24:39.702712883Z   '@colyseus/schema': '^1.0.34',
579bf4f559-bknmd | 2022-04-05T03:24:39.702714733Z   '@colyseus/uwebsockets-transport': '^0.14.27',
579bf4f559-bknmd | 2022-04-05T03:24:39.702716713Z   '@prisma/client': '^3.11.0',
579bf4f559-bknmd | 2022-04-05T03:24:39.702718803Z   colyseus: '^0.14.23',
579bf4f559-bknmd | 2022-04-05T03:24:39.702720552Z   dotenv: '^14.2.0',
579bf4f559-bknmd | 2022-04-05T03:24:39.702722283Z   lodash: '^4.17.21',
579bf4f559-bknmd | 2022-04-05T03:24:39.702724103Z   prisma: '^3.11.0',
579bf4f559-bknmd | 2022-04-05T03:24:39.702725903Z   'ts-node-dev': '^1.1.8',
579bf4f559-bknmd | 2022-04-05T03:24:39.702727783Z   typescript: '^4.6.2',
579bf4f559-bknmd | 2022-04-05T03:24:39.702730153Z   xstate: '^4.30.3'
579bf4f559-bknmd | 2022-04-05T03:24:39.702731863Z }
579bf4f559-bknmd | 2022-04-05T03:24:39.702733553Z Skipping item: @colyseus/arena - cannot be updated on package.json.
579bf4f559-bknmd | 2022-04-05T03:24:39.702737113Z Skipping item: @colyseus/core - cannot be updated on package.json.
579bf4f559-bknmd | 2022-04-05T03:24:39.702756964Z Skipping item: @colyseus/monitor - cannot be updated on package.json.
579bf4f559-bknmd | 2022-04-05T03:24:39.702761183Z Skipping item: @colyseus/schema - cannot be updated on package.json.
579bf4f559-bknmd | 2022-04-05T03:24:39.702815145Z Skipping item: colyseus - cannot be updated on package.json.
579bf4f559-bknmd | 2022-04-05T03:24:39.702821845Z Adding Org Workspaces
579bf4f559-bknmd | 2022-04-05T03:24:39.703344005Z New Package JSON merge completed
579bf4f559-bknmd | 2022-04-05T03:24:44.781121129Z Running NPM Install...
579bf4f559-bknmd | 2022-04-05T03:26:25.288190303Z 
579bf4f559-bknmd | 2022-04-05T03:26:25.288231704Z > postinstall
579bf4f559-bknmd | 2022-04-05T03:26:25.288235444Z > npm run boot
579bf4f559-bknmd | 2022-04-05T03:26:25.288237474Z 
579bf4f559-bknmd | 2022-04-05T03:26:26.993580554Z 
579bf4f559-bknmd | 2022-04-05T03:26:26.993607944Z > boot
579bf4f559-bknmd | 2022-04-05T03:26:26.993611504Z > lerna bootstrap
579bf4f559-bknmd | 2022-04-05T03:26:26.993613624Z 
579bf4f559-bknmd | 2022-04-05T03:26:28.482520406Z lerna notice cli v4.0.0
579bf4f559-bknmd | 2022-04-05T03:26:28.679832041Z lerna info Bootstrapping 0 package
579bf4f559-bknmd | 2022-04-05T03:26:28.681339319Z lerna info Symlinking packages and binaries
579bf4f559-bknmd | 2022-04-05T03:26:28.681507513Z lerna success Bootstrapped 0 package
579bf4f559-bknmd | 2022-04-05T03:26:28.791489264Z 
579bf4f559-bknmd | 2022-04-05T03:26:28.791534945Z added 23 packages, removed 74 packages, changed 4 packages, and audited 248 packages in 2m
579bf4f559-bknmd | 2022-04-05T03:26:28.791555825Z 
579bf4f559-bknmd | 2022-04-05T03:26:28.791558326Z 12 packages are looking for funding
579bf4f559-bknmd | 2022-04-05T03:26:28.791561285Z   run `npm fund` for details
579bf4f559-bknmd | 2022-04-05T03:26:28.792513514Z 
579bf4f559-bknmd | 2022-04-05T03:26:28.792534084Z found 0 vulnerabilities
579bf4f559-bknmd | 2022-04-05T03:26:28.793028984Z npm notice 
579bf4f559-bknmd | 2022-04-05T03:26:28.793079945Z npm notice New minor version of npm available! 8.5.2 -> 8.6.0
579bf4f559-bknmd | 2022-04-05T03:26:28.793096315Z npm notice Changelog: <https://github.com/npm/cli/releases/tag/v8.6.0>
579bf4f559-bknmd | 2022-04-05T03:26:28.793100775Z npm notice Run `npm install -g npm@8.6.0` to update!
579bf4f559-bknmd | 2022-04-05T03:26:28.793122806Z npm notice 
579bf4f559-bknmd | 2022-04-05T03:26:30.198706807Z npm WARN using --force Recommended protections disabled.
579bf4f559-bknmd | 2022-04-05T03:26:35.584053127Z --- Completed Prelaunch ---
579bf4f559-bknmd | 2022-04-05T03:26:36.603600835Z Arena-Env (arena.env):
579bf4f559-bknmd | 2022-04-05T03:26:36.603774379Z {
579bf4f559-bknmd | 2022-04-05T03:26:36.603785160Z     "NODE_ENV": "production"
579bf4f559-bknmd | 2022-04-05T03:26:36.603789119Z }
579bf4f559-bknmd | 2022-04-05T03:26:36.603791920Z NODE_ENV has been overridden to 'production'
579bf4f559-bknmd | 2022-04-05T03:26:36.809373902Z INFO : Arena-Config: No valid file provided
579bf4f559-bknmd | 2022-04-05T03:26:36.809582356Z INFO : *** Have you DEPLOYED your server code? ****
579bf4f559-bknmd | 2022-04-05T03:26:36.810804520Z Error: @prisma/client did not initialize yet. Please run "prisma generate" and try to import it again.
579bf4f559-bknmd | 2022-04-05T03:26:36.810817750Z In case this error is unexpected for you, please report it in https://github.com/prisma/prisma/issues
579bf4f559-bknmd | 2022-04-05T03:26:36.810820400Z     at new PrismaClient (/colyseus/node_modules/.prisma/client/index.js:3:11)
579bf4f559-bknmd | 2022-04-05T03:26:36.810822630Z     at Object.317 (/colyseus/app/server/arena/index.js:1:130)
579bf4f559-bknmd | 2022-04-05T03:26:36.810826150Z     at i (/colyseus/app/server/arena/index.js:1:111497)
579bf4f559-bknmd | 2022-04-05T03:26:36.810828190Z     at Object.384 (/colyseus/app/server/arena/index.js:1:24416)
579bf4f559-bknmd | 2022-04-05T03:26:36.810837980Z     at i (/colyseus/app/server/arena/index.js:1:111497)
579bf4f559-bknmd | 2022-04-05T03:26:36.810840001Z     at /colyseus/app/server/arena/index.js:1:111537
579bf4f559-bknmd | 2022-04-05T03:26:36.810841931Z     at Object.<anonymous> (/colyseus/app/server/arena/index.js:1:111638)
579bf4f559-bknmd | 2022-04-05T03:26:36.810844151Z     at Module._compile (internal/modules/cjs/loader.js:1085:14)
579bf4f559-bknmd | 2022-04-05T03:26:36.810846160Z     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
579bf4f559-bknmd | 2022-04-05T03:26:36.810848161Z     at Module.load (internal/modules/cjs/loader.js:950:32)
579bf4f559-bknmd | 2022-04-05T03:26:36.815115934Z No Transport provided... Arena is Defaulting to uWS
579bf4f559-bknmd | 2022-04-05T03:26:36.815642715Z ✅ uWebSockets.js + Express compatibility enabled
579bf4f559-bknmd | 2022-04-05T03:26:36.879699248Z Colyseus 0.14.18_Node-14.17.3-Buster_uWS_WS_RD_v3: Listening on ws://ir-sgl.colyseus.de:2567
579bf4f559-bknmd | 

Hi, I think you're right. When deployed on Arena Cloud your package.json file is not fully used by your deployment. Arena Cloud copies the custom dependencies into a managed Arena package.json which is then installed at the launch of your server. I'll find some way to help initialize the prisma.

Thanks @COCO !
Is this related to the package itself not firing it's built-in postinstall as well?

@jdansercoer
No, I think Arena ignores postinstall scripts in every package.json, I'm asking our support to make sure.

@COCO Do you have an update on this? This is a huge blocker for us and prevents us from using Colyseus Arena at all..

Your support ticket is now on review but I don't have permission to access ticket system.

@jdansercoer I've found a workaround for this problem.

I use manual deployments via server code uploading in UI.

By default prisma generate creates client code in node_modules/.prisma/client and @prisma/client expects to find client and types there. If client is not generated you see this error Error: @prisma/client did not initialize yet. Please run "prisma generate" and try to import it again..
It's possible to change default location for generated code to allow prisma to load it from there. This is what I use to include generated client to my src folder which will be included into final build which I upload in UI.

generator client {
  provider = "prisma-client-js"
  output   = "../src/db/client"
  binaryTargets = ["native", "debian-openssl-1.1.x"]
}

Note: make sure to import your client from generated code (import { PrismaClient } from "../db/client";
by providing generated Prisma client outside of node_modules/ you make it unnecessary to run use postinstall script.

General solution:

  1. Change Prisma config to store generated client outside of node_modules
  2. Change imports to point directly to generate client.
  3. Make sure to include generated client into deployment. E.g. include yarn copyfiles -u 1 \"src/db/**/*\" ./build into build step.