This package contains a postinstall script to perform the photon package generation.
I am leveraging an environment variable for my db connection string. Unless I make this env var available before running npm install the postinstall of this package will fall over.
See example output:
โฏ npm install
npm WARN rm not removing /prisma2-pg-jest/node_modules/.bin/semver as it wasn't installed by /prisma2-pg-jest/node_modules/semver
npm WARN rm not removing /prisma2-pg-jest/node_modules/fsevents/node_modules/.bin/node-pre-gyp as it wasn't installed by /prisma2-pg-jest/node_modules/fsevents/node_modules/node-pre-gyp
> [email protected] install /prisma2-pg-jest/node_modules/fsevents
> node install
node-pre-gyp WARN Using request for node-pre-gyp https download
[fsevents] Success: "/prisma2-pg-jest/node_modules/fsevents/lib/binding/Release/node-v72-darwin-x64/fse.node" is installed via remote
> [email protected] install /prisma2-pg-jest/node_modules/prisma2
> node download-build/index.js || echo "Have fun with prisma2!"
> Downloading Prisma engines for darwin [====================] 100%
> @prisma/[email protected] postinstall /prisma2-pg-jest/node_modules/@prisma/photon
> node scripts/generate.js
Error: Schema parsing
error: Environment variable not found: POSTGRES_URL.
--> schema.prisma:7
|
6 | provider = "postgresql"
7 | url = env("POSTGRES_URL")
8 | }
|
added 40 packages from 15 contributors, removed 77 packages, updated 530 packages and audited 886740 packages in 16.184s
found 0 vulnerabilities
To be clear, I don't have any postinstall defined in my project. It appears to be explicitly executing the one defined within @prisma/photon
I'd personally prefer to explicitly call the prisma2 generate myself, either manually, or in mine own postinstall script.
I've had the same issue.
To add to that, it's consistently using the old @prisma/photon version (preview 018.2) for me as well, even though I'm on the latest version (alpha.451)


Is it possible this is NPM specific?
Terminal screenshots from both
npm install & yarn install



We are aware that currently environment variables are required to be present if you define them in your schema. We have an open issue about this: https://github.com/prisma/prisma2/issues/800
In the meanwhile, you can just create .env file with empty envs as a workaround.
@pantharshit00 https://github.com/prisma/photonjs/issues/326 was closed prematurely.
prisma2 generateThe postinstall command - which automatically runs when you run npm install - is the cause of the error. The original log provided here by @ctrlplusb illustrates that: https://github.com/prisma/photonjs/issues/326#issue-537085896
And the screenshot I provided here shows how prisma2 generate works as expected immediately after getting the error triggered by postinstall calling node scripts/generate.js
Thanks for reporting!
Before tackling this, we need to create a spec on how to handle env vars in Prisma in general.
Most helpful comment
@pantharshit00 https://github.com/prisma/photonjs/issues/326 was closed prematurely.
prisma2 generateThe
postinstallcommand - which automatically runs when you run npm install - is the cause of the error. The original log provided here by @ctrlplusb illustrates that: https://github.com/prisma/photonjs/issues/326#issue-537085896And the screenshot I provided here shows how
prisma2 generateworks as expected immediately after getting the error triggered bypostinstallcallingnode scripts/generate.js