Redwood: Error generating the Prisma client

Created on 8 Apr 2020  ·  22Comments  ·  Source: redwoodjs/redwood

I am following the tutorial here https://redwoodjs.com/tutorial/installation-starting-development, and am running into an error. Here are my project files (just the generated starter files minus the node_modules folder) and the commands I've run:

Project zip: redwoodblog.zip

$ node -v
v13.12.0
$ yarn -v
1.22.4
$ yarn create redwood-app ./redwoodblog

yarn create v1.22.4
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
success Installed "[email protected]" with binaries:
      - create-redwood-app
  ✔ Creating Redwood app
    ✔ Creating directory '/Users/Andrew/RedwoodJS_Tutorial/redwoodblog'
    ✔ Downloading latest release
    ✔ Extracting latest release
    ✔ Clean up
  ✔ Installing packages
    ✔ Checking node and yarn compatibility
    ✔ Running `yarn install`... (This could take a while)

Thanks for trying out Redwood! We've created your app in '/Users/Andrew/RedwoodJS_Tutorial/redwoodblog'

Inside that directory you can run `yarn rw dev` to start the development server.
✨  Done in 119.41s.

Error Output: yarn rw dev

Click details below to view.

$ cd redwoodblog
$ yarn rw dev

yarn run v1.22.4
$ '/Users/Andrew/RedwoodJS_Tutorial/redwoodblog/node_modules/.bin/rw' dev
  ✖ Generating the Prisma client...
    → info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Command failed with exit code 1: yarn prisma2 generate
Error: Cannot call write after a stream was destroyed
error Command failed with exit code 1.
$ '/Users/Andrew/RedwoodJS_Tutorial/redwoodblog/node_modules/.bin/prisma2' generate
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
$ '/Users/Andrew/RedwoodJS_Tutorial/redwoodblog/node_modules/.bin/dev-server'
$ '/Users/Andrew/RedwoodJS_Tutorial/redwoodblog/node_modules/.bin/webpack-dev-server' --config ../node_modules/@redwoodjs/core/config/webpack.development.js
$ '/Users/Andrew/RedwoodJS_Tutorial/redwoodblog/node_modules/.bin/prisma2' generate --watch
21:39:28  db | Error: Cannot call write after a stream was destroyed
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
21:39:28  db | cd /Users/Andrew/RedwoodJS_Tutorial/redwoodblog/api && yarn prisma2 generate --watch exited with code 1
21:39:28  db | cd /Users/Andrew/RedwoodJS_Tutorial/redwoodblog/api && yarn prisma2 generate --watch restarted
$ '/Users/Andrew/RedwoodJS_Tutorial/redwoodblog/node_modules/.bin/prisma2' generate --watch
21:39:30  db | Error: Cannot call write after a stream was destroyed
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
21:39:30  db | cd /Users/Andrew/RedwoodJS_Tutorial/redwoodblog/api && yarn prisma2 generate --watch exited with code 1
21:39:30  db | cd /Users/Andrew/RedwoodJS_Tutorial/redwoodblog/api && yarn prisma2 generate --watch restarted
$ '/Users/Andrew/RedwoodJS_Tutorial/redwoodblog/node_modules/.bin/prisma2' generate --watch
21:39:30 web | ℹ 「wds」: Project is running at http://localhost:8910/
21:39:30 web | ℹ 「wds」: webpack output is served from /
21:39:30 web | ℹ 「wds」: Content not from webpack is served from /Users/Andrew/RedwoodJS_Tutorial/redwoodblog/web
21:39:30 web | ℹ 「wds」: 404s will fallback to /index.html
21:39:33  db | Error: Cannot call write after a stream was destroyed
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
21:39:33  db | cd /Users/Andrew/RedwoodJS_Tutorial/redwoodblog/api && yarn prisma2 generate --watch exited with code 1
21:39:33  db | cd /Users/Andrew/RedwoodJS_Tutorial/redwoodblog/api && yarn prisma2 generate --watch restarted
21:39:33 api | /Users/Andrew/RedwoodJS_Tutorial/redwoodblog/node_modules/@prisma/client/index.js:3
21:39:33 api |     throw new Error(
21:39:33 api |     ^
21:39:33 api | 
21:39:33 api | Error: @prisma/client did not initialize yet. Please run "prisma2 generate" and try to import it again.
21:39:33 api | In case this error is unexpected for you, please report it in https://github.com/prisma/prisma-client-js/issues/390.
21:39:33 api |     at new PrismaClient (/Users/Andrew/RedwoodJS_Tutorial/redwoodblog/node_modules/@prisma/client/index.js:3:11)
21:39:33 api |     at Object.<anonymous> (/Users/Andrew/RedwoodJS_Tutorial/redwoodblog/api/src/lib/db.js:6:19)
21:39:33 api |     at Module._compile (internal/modules/cjs/loader.js:1147:30)
21:39:33 api |     at Module._compile (/Users/Andrew/RedwoodJS_Tutorial/redwoodblog/node_modules/pirates/lib/index.js:99:24)
21:39:33 api |     at Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
21:39:33 api |     at Object.newLoader [as .js] (/Users/Andrew/RedwoodJS_Tutorial/redwoodblog/node_modules/pirates/lib/index.js:104:7)
21:39:33 api |     at Module.load (internal/modules/cjs/loader.js:996:32)
21:39:33 api |     at Function.Module._load (internal/modules/cjs/loader.js:896:14)
21:39:33 api |     at Module.require (internal/modules/cjs/loader.js:1036:19)
21:39:33 api |     at require (internal/modules/cjs/helpers.js:72:18)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
21:39:33 api | cd /Users/Andrew/RedwoodJS_Tutorial/redwoodblog/api && yarn dev-server exited with code 1
21:39:33 api | cd /Users/Andrew/RedwoodJS_Tutorial/redwoodblog/api && yarn dev-server restarted
$ '/Users/Andrew/RedwoodJS_Tutorial/redwoodblog/node_modules/.bin/prisma2' generate --watch
$ '/Users/Andrew/RedwoodJS_Tutorial/redwoodblog/node_modules/.bin/dev-server'
21:39:35  db | Error: Cannot call write after a stream was destroyed
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
21:39:35  db | cd /Users/Andrew/RedwoodJS_Tutorial/redwoodblog/api && yarn prisma2 generate --watch exited with code 1
21:39:37 api | /Users/Andrew/RedwoodJS_Tutorial/redwoodblog/node_modules/@prisma/client/index.js:3
21:39:37 api |     throw new Error(
21:39:37 api |     ^
21:39:37 api | 
21:39:37 api | Error: @prisma/client did not initialize yet. Please run "prisma2 generate" and try to import it again.
21:39:37 api | In case this error is unexpected for you, please report it in https://github.com/prisma/prisma-client-js/issues/390.
21:39:37 api |     at new PrismaClient (/Users/Andrew/RedwoodJS_Tutorial/redwoodblog/node_modules/@prisma/client/index.js:3:11)
21:39:37 api |     at Object.<anonymous> (/Users/Andrew/RedwoodJS_Tutorial/redwoodblog/api/src/lib/db.js:6:19)
21:39:37 api |     at Module._compile (internal/modules/cjs/loader.js:1147:30)
21:39:37 api |     at Module._compile (/Users/Andrew/RedwoodJS_Tutorial/redwoodblog/node_modules/pirates/lib/index.js:99:24)
21:39:37 api |     at Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
21:39:37 api |     at Object.newLoader [as .js] (/Users/Andrew/RedwoodJS_Tutorial/redwoodblog/node_modules/pirates/lib/index.js:104:7)
21:39:37 api |     at Module.load (internal/modules/cjs/loader.js:996:32)
21:39:37 api |     at Function.Module._load (internal/modules/cjs/loader.js:896:14)
21:39:37 api |     at Module.require (internal/modules/cjs/loader.js:1036:19)
21:39:37 api |     at require (internal/modules/cjs/helpers.js:72:18)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
21:39:38 api | cd /Users/Andrew/RedwoodJS_Tutorial/redwoodblog/api && yarn dev-server exited with code 1
21:39:38 api | cd /Users/Andrew/RedwoodJS_Tutorial/redwoodblog/api && yarn dev-server restarted
$ '/Users/Andrew/RedwoodJS_Tutorial/redwoodblog/node_modules/.bin/dev-server'
21:39:43 api | /Users/Andrew/RedwoodJS_Tutorial/redwoodblog/node_modules/@prisma/client/index.js:3
21:39:43 api |     throw new Error(
21:39:43 api |     ^
21:39:43 api | 
21:39:43 api | Error: @prisma/client did not initialize yet. Please run "prisma2 generate" and try to import it again.
21:39:43 api | In case this error is unexpected for you, please report it in https://github.com/prisma/prisma-client-js/issues/390.
21:39:43 api |     at new PrismaClient (/Users/Andrew/RedwoodJS_Tutorial/redwoodblog/node_modules/@prisma/client/index.js:3:11)
21:39:43 api |     at Object.<anonymous> (/Users/Andrew/RedwoodJS_Tutorial/redwoodblog/api/src/lib/db.js:6:19)
21:39:43 api |     at Module._compile (internal/modules/cjs/loader.js:1147:30)
21:39:43 api |     at Module._compile (/Users/Andrew/RedwoodJS_Tutorial/redwoodblog/node_modules/pirates/lib/index.js:99:24)
21:39:43 api |     at Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
    at Object.newLoader [as .js] (/Users/Andrew/RedwoodJS_Tutorial/redwoodblog/node_modules/pirates/lib/index.js:104:7)
21:39:43 api |     at Module.load (internal/modules/cjs/loader.js:996:32)
21:39:43 api |     at Function.Module._load (internal/modules/cjs/loader.js:896:14)
21:39:43 api |     at Module.require (internal/modules/cjs/loader.js:1036:19)
21:39:43 api |     at require (internal/modules/cjs/helpers.js:72:18)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
21:39:43 api | cd /Users/Andrew/RedwoodJS_Tutorial/redwoodblog/api && yarn dev-server exited with code 1
21:39:43 api | cd /Users/Andrew/RedwoodJS_Tutorial/redwoodblog/api && yarn dev-server restarted
$ '/Users/Andrew/RedwoodJS_Tutorial/redwoodblog/node_modules/.bin/dev-server'
21:39:49 api | /Users/Andrew/RedwoodJS_Tutorial/redwoodblog/node_modules/@prisma/client/index.js:3
21:39:49 api |     throw new Error(
21:39:49 api |     ^
21:39:49 api | 
21:39:49 api | Error: @prisma/client did not initialize yet. Please run "prisma2 generate" and try to import it again.
21:39:49 api | In case this error is unexpected for you, please report it in https://github.com/prisma/prisma-client-js/issues/390.
21:39:49 api |     at new PrismaClient (/Users/Andrew/RedwoodJS_Tutorial/redwoodblog/node_modules/@prisma/client/index.js:3:11)
21:39:49 api |     at Object.<anonymous> (/Users/Andrew/RedwoodJS_Tutorial/redwoodblog/api/src/lib/db.js:6:19)
21:39:49 api |     at Module._compile (internal/modules/cjs/loader.js:1147:30)
21:39:49 api |     at Module._compile (/Users/Andrew/RedwoodJS_Tutorial/redwoodblog/node_modules/pirates/lib/index.js:99:24)
21:39:49 api |     at Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
21:39:49 api |     at Object.newLoader [as .js] (/Users/Andrew/RedwoodJS_Tutorial/redwoodblog/node_modules/pirates/lib/index.js:104:7)
21:39:49 api |     at Module.load (internal/modules/cjs/loader.js:996:32)
21:39:49 api |     at Function.Module._load (internal/modules/cjs/loader.js:896:14)
21:39:49 api |     at Module.require (internal/modules/cjs/loader.js:1036:19)
21:39:49 api |     at require (internal/modules/cjs/helpers.js:72:18)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
21:39:49 api | cd /Users/Andrew/RedwoodJS_Tutorial/redwoodblog/api && yarn dev-server exited with code 1

bu2-confirmed kinbug prisma

Most helpful comment

Hi @TurboTobias,

See this issue: https://github.com/prisma/prisma/issues/1973
From your console output here it seems that the path Mobile Documents includes space. I suggest trying from a new system path

All 22 comments

@AndrewSverdrup thank you for reporting this. And sorry you ran into issues right out of the gate.

I used the .zip you included to test locally. I was unable to reproduce the error (yay/boo).

If you are still experiencing this, could you try the following:

Note: this will destroy any uncommitted work you have done

  • Remove all git-ignored files and uncommitted changes: git clean -fxd
  • Remove prisma cache: rm -rf ~/.cache/prisma
  • Re-install packages: yarn install
  • Do over! yarn rw dev

🤞😬

Followed your steps and got the same result @thedavidprice

Removed global prisma CLI just to be sure.

Also, now created an entirely new project with instructions form https://redwoodjs.com/tutorial/installation-starting-development

  1. yarn create redwood-app ./redwoodblog
  2. cd redwoodblog
  3. yarn redwood dev

Same error as printed above :/

Full log

tobias@Tobiass-MacBook-Pro test-redwood % npm uninstall -g prisma --save
up to date in 0.04s
tobias@Tobiass-MacBook-Pro test-redwood % npm uninstall -g prisma2 --save
up to date in 0.034s
tobias@Tobiass-MacBook-Pro test-redwood % npm uninstall -g @prisma/cli
up to date in 0.032s
tobias@Tobiass-MacBook-Pro test-redwood % cd ../
tobias@Tobiass-MacBook-Pro Web % yarn create redwood-app ./redwoodblog
yarn create v1.21.1
warning package.json: No license field
[1/4] 🔍 Resolving packages...
[2/4] 🚚 Fetching packages...
[3/4] 🔗 Linking dependencies...
warning " > @react-native-community/[email protected]" has unmet peer dependency "react-native@^0.62.0-rc.0".
warning "@react-native-community/cli > [email protected]" has unmet peer dependency "@babel/core@*".
[4/4] 🔨 Building fresh packages...
success Installed "[email protected]" with binaries:
- create-redwood-app
✔ Creating Redwood app
✔ Creating directory '/Users/tobias/Library/Mobile Documents/com~apple~CloudDocs/Web/redwoodblog'
✔ Downloading latest release
✔ Extracting latest release
✔ Clean up
✔ Installing packages
✔ Checking node and yarn compatibility
✔ Running `yarn install`... (This could take a while)

Thanks for trying out Redwood! We've created your app in '/Users/tobias/Library/Mobile Documents/com~apple~CloudDocs/Web/redwoodblog'

Inside that directory you can run `yarn rw dev` to start the development server.
✨ Done in 30.18s.
tobias@Tobiass-MacBook-Pro Web % cd redwoodblog
tobias@Tobiass-MacBook-Pro redwoodblog % yarn redwood dev
yarn run v1.21.1
$ '/Users/tobias/Library/Mobile Documents/com~apple~CloudDocs/Web/redwoodblog/node_modules/.bin/redwood' dev
✖ Generating the Prisma client...
→ info Visit [https://yarnpkg.com/en/docs/cli/run](https://yarnpkg.com/en/docs/cli/run) for documentation about this command.
Command failed with exit code 1: yarn prisma2 generate
Error: Cannot call write after a stream was destroyed
error Command failed with exit code 1.
$ '/Users/tobias/Library/Mobile Documents/com~apple~CloudDocs/Web/redwoodblog/node_modules/.bin/prisma2' generate
info Visit [https://yarnpkg.com/en/docs/cli/run](https://yarnpkg.com/en/docs/cli/run) for documentation about this command.
$ '/Users/tobias/Library/Mobile Documents/com~apple~CloudDocs/Web/redwoodblog/node_modules/.bin/dev-server'
$ '/Users/tobias/Library/Mobile Documents/com~apple~CloudDocs/Web/redwoodblog/node_modules/.bin/prisma2' generate --watch
$ '/Users/tobias/Library/Mobile Documents/com~apple~CloudDocs/Web/redwoodblog/node_modules/.bin/webpack-dev-server' --config ../node_modules/@redwoodjs/core/config/webpack.development.js
14:32:40 db | Error: Cannot call write after a stream was destroyed
error Command failed with exit code 1.
info Visit [https://yarnpkg.com/en/docs/cli/run](https://yarnpkg.com/en/docs/cli/run) for documentation about this command.
14:32:40 db | cd /Users/tobias/Library/Mobile\ Documents/com~apple~CloudDocs/Web/redwoodblog/api && yarn prisma2 generate --watch exited with code 1
14:32:40 db | cd /Users/tobias/Library/Mobile\ Documents/com~apple~CloudDocs/Web/redwoodblog/api && yarn prisma2 generate --watch restarted
$ '/Users/tobias/Library/Mobile Documents/com~apple~CloudDocs/Web/redwoodblog/node_modules/.bin/prisma2' generate --watch
14:32:41 web | ℹ 「wds」: Project is running at [http://localhost:8910/](http://localhost:8910/)
14:32:41 web | ℹ 「wds」: webpack output is served from /
14:32:41 web | ℹ 「wds」: Content not from webpack is served from /Users/tobias/Library/Mobile Documents/com~apple~CloudDocs/Web/redwoodblog/web
14:32:41 web | ℹ 「wds」: 404s will fallback to /index.html
14:32:41 api | /Users/tobias/Library/Mobile Documents/com~apple~CloudDocs/Web/redwoodblog/node_modules/@prisma/client/index.js:3
14:32:41 api | throw new Error(
14:32:41 api | ^
14:32:41 api |
14:32:41 api | Error: @prisma/client did not initialize yet. Please run "prisma2 generate" and try to import it again.
14:32:41 api | In case this error is unexpected for you, please report it in [https://github.com/prisma/prisma-client-js/issues/390](https://github.com/prisma/prisma-client-js/issues/390).
14:32:41 api | at new PrismaClient (/Users/tobias/Library/Mobile Documents/com~apple~CloudDocs/Web/redwoodblog/node_modules/@prisma/client/index.js:3:11)
14:32:41 api | at Object.<anonymous> (/Users/tobias/Library/Mobile Documents/com~apple~CloudDocs/Web/redwoodblog/api/src/lib/db.js:6:19)
14:32:41 api | at Module._compile (internal/modules/cjs/loader.js:1151:30)
14:32:41 api | at Module._compile (/Users/tobias/Library/Mobile Documents/com~apple~CloudDocs/Web/redwoodblog/node_modules/pirates/lib/index.js:99:24)
14:32:41 api | at Module._extensions..js (internal/modules/cjs/loader.js:1171:10)
14:32:41 api | at Object.newLoader [as .js] (/Users/tobias/Library/Mobile Documents/com~apple~CloudDocs/Web/redwoodblog/node_modules/pirates/lib/index.js:104:7)
14:32:41 api | at Module.load (internal/modules/cjs/loader.js:1000:32)
14:32:41 api | at Function.Module._load (internal/modules/cjs/loader.js:899:14)
14:32:41 api | at Module.require (internal/modules/cjs/loader.js:1040:19)
14:32:41 api | at require (internal/modules/cjs/helpers.js:72:18)
error Command failed with exit code 1.
info Visit [https://yarnpkg.com/en/docs/cli/run](https://yarnpkg.com/en/docs/cli/run) for documentation about this command.
14:32:41 api | cd /Users/tobias/Library/Mobile\ Documents/com~apple~CloudDocs/Web/redwoodblog/api && yarn dev-server exited with code 1
14:32:41 api | cd /Users/tobias/Library/Mobile\ Documents/com~apple~CloudDocs/Web/redwoodblog/api && yarn dev-server restarted
$ '/Users/tobias/Library/Mobile Documents/com~apple~CloudDocs/Web/redwoodblog/node_modules/.bin/dev-server'
14:32:41 db | Error: Cannot call write after a stream was destroyed
error Command failed with exit code 1.
info Visit [https://yarnpkg.com/en/docs/cli/run](https://yarnpkg.com/en/docs/cli/run) for documentation about this command.
14:32:41 db | cd /Users/tobias/Library/Mobile\ Documents/com~apple~CloudDocs/Web/redwoodblog/api && yarn prisma2 generate --watch exited with code 1
14:32:41 db | cd /Users/tobias/Library/Mobile\ Documents/com~apple~CloudDocs/Web/redwoodblog/api && yarn prisma2 generate --watch restarted
$ '/Users/tobias/Library/Mobile Documents/com~apple~CloudDocs/Web/redwoodblog/node_modules/.bin/prisma2' generate --watch
14:32:42 db | Error: Cannot call write after a stream was destroyed
error Command failed with exit code 1.
info Visit [https://yarnpkg.com/en/docs/cli/run](https://yarnpkg.com/en/docs/cli/run) for documentation about this command.
14:32:42 db | cd /Users/tobias/Library/Mobile\ Documents/com~apple~CloudDocs/Web/redwoodblog/api && yarn prisma2 generate --watch exited with code 1
14:32:42 db | cd /Users/tobias/Library/Mobile\ Documents/com~apple~CloudDocs/Web/redwoodblog/api && yarn prisma2 generate --watch restarted
$ '/Users/tobias/Library/Mobile Documents/com~apple~CloudDocs/Web/redwoodblog/node_modules/.bin/prisma2' generate --watch
14:32:42 api | /Users/tobias/Library/Mobile Documents/com~apple~CloudDocs/Web/redwoodblog/node_modules/@prisma/client/index.js:3
14:32:42 api | throw new Error(
14:32:42 api | ^
14:32:42 api |
14:32:42 api | Error: @prisma/client did not initialize yet. Please run "prisma2 generate" and try to import it again.
14:32:42 api | In case this error is unexpected for you, please report it in [https://github.com/prisma/prisma-client-js/issues/390](https://github.com/prisma/prisma-client-js/issues/390).
14:32:42 api | at new PrismaClient (/Users/tobias/Library/Mobile Documents/com~apple~CloudDocs/Web/redwoodblog/node_modules/@prisma/client/index.js:3:11)
14:32:42 api | at Object.<anonymous> (/Users/tobias/Library/Mobile Documents/com~apple~CloudDocs/Web/redwoodblog/api/src/lib/db.js:6:19)
14:32:42 api | at Module._compile (internal/modules/cjs/loader.js:1151:30)
14:32:42 api | at Module._compile (/Users/tobias/Library/Mobile Documents/com~apple~CloudDocs/Web/redwoodblog/node_modules/pirates/lib/index.js:99:24)
14:32:42 api | at Module._extensions..js (internal/modules/cjs/loader.js:1171:10)
14:32:42 api | at Object.newLoader [as .js] (/Users/tobias/Library/Mobile Documents/com~apple~CloudDocs/Web/redwoodblog/node_modules/pirates/lib/index.js:104:7)
14:32:42 api | at Module.load (internal/modules/cjs/loader.js:1000:32)
14:32:42 api | at Function.Module._load (internal/modules/cjs/loader.js:899:14)
14:32:42 api | at Module.require (internal/modules/cjs/loader.js:1040:19)
14:32:42 api | at require (internal/modules/cjs/helpers.js:72:18)
error Command failed with exit code 1.
info Visit [https://yarnpkg.com/en/docs/cli/run](https://yarnpkg.com/en/docs/cli/run) for documentation about this command.
14:32:43 api | cd /Users/tobias/Library/Mobile\ Documents/com~apple~CloudDocs/Web/redwoodblog/api && yarn dev-server exited with code 1
14:32:43 api | cd /Users/tobias/Library/Mobile\ Documents/com~apple~CloudDocs/Web/redwoodblog/api && yarn dev-server restarted
$ '/Users/tobias/Library/Mobile Documents/com~apple~CloudDocs/Web/redwoodblog/node_modules/.bin/dev-server'
14:32:43 db | Error: Cannot call write after a stream was destroyed
error Command failed with exit code 1.
info Visit [https://yarnpkg.com/en/docs/cli/run](https://yarnpkg.com/en/docs/cli/run) for documentation about this command.
14:32:43 db | cd /Users/tobias/Library/Mobile\ Documents/com~apple~CloudDocs/Web/redwoodblog/api && yarn prisma2 generate --watch exited with code 1
14:32:44 api | /Users/tobias/Library/Mobile Documents/com~apple~CloudDocs/Web/redwoodblog/node_modules/@prisma/client/index.js:3
14:32:44 api | throw new Error(
14:32:44 api | ^
14:32:44 api |
14:32:44 api | Error: @prisma/client did not initialize yet. Please run "prisma2 generate" and try to import it again.
14:32:44 api | In case this error is unexpected for you, please report it in [https://github.com/prisma/prisma-client-js/issues/390](https://github.com/prisma/prisma-client-js/issues/390).
14:32:44 api | at new PrismaClient (/Users/tobias/Library/Mobile Documents/com~apple~CloudDocs/Web/redwoodblog/node_modules/@prisma/client/index.js:3:11)
14:32:44 api | at Object.<anonymous> (/Users/tobias/Library/Mobile Documents/com~apple~CloudDocs/Web/redwoodblog/api/src/lib/db.js:6:19)
14:32:44 api | at Module._compile (internal/modules/cjs/loader.js:1151:30)
14:32:44 api | at Module._compile (/Users/tobias/Library/Mobile Documents/com~apple~CloudDocs/Web/redwoodblog/node_modules/pirates/lib/index.js:99:24)
14:32:44 api | at Module._extensions..js (internal/modules/cjs/loader.js:1171:10)
14:32:44 api | at Object.newLoader [as .js] (/Users/tobias/Library/Mobile Documents/com~apple~CloudDocs/Web/redwoodblog/node_modules/pirates/lib/index.js:104:7)
14:32:44 api | at Module.load (internal/modules/cjs/loader.js:1000:32)
14:32:44 api | at Function.Module._load (internal/modules/cjs/loader.js:899:14)
14:32:44 api | at Module.require (internal/modules/cjs/loader.js:1040:19)
14:32:44 api | at require (internal/modules/cjs/helpers.js:72:18)
error Command failed with exit code 1.
info Visit [https://yarnpkg.com/en/docs/cli/run](https://yarnpkg.com/en/docs/cli/run) for documentation about this command.
14:32:44 api | cd /Users/tobias/Library/Mobile\ Documents/com~apple~CloudDocs/Web/redwoodblog/api && yarn dev-server exited with code 1
14:32:44 api | cd /Users/tobias/Library/Mobile\ Documents/com~apple~CloudDocs/Web/redwoodblog/api && yarn dev-server restarted
$ '/Users/tobias/Library/Mobile Documents/com~apple~CloudDocs/Web/redwoodblog/node_modules/.bin/dev-server'
14:32:46 api | /Users/tobias/Library/Mobile Documents/com~apple~CloudDocs/Web/redwoodblog/node_modules/@prisma/client/index.js:3
14:32:46 api | throw new Error(
14:32:46 api | ^
14:32:46 api |
14:32:46 api | Error: @prisma/client did not initialize yet. Please run "prisma2 generate" and try to import it again.
14:32:46 api | In case this error is unexpected for you, please report it in [https://github.com/prisma/prisma-client-js/issues/390](https://github.com/prisma/prisma-client-js/issues/390).
14:32:46 api | at new PrismaClient (/Users/tobias/Library/Mobile Documents/com~apple~CloudDocs/Web/redwoodblog/node_modules/@prisma/client/index.js:3:11)
14:32:46 api | at Object.<anonymous> (/Users/tobias/Library/Mobile Documents/com~apple~CloudDocs/Web/redwoodblog/api/src/lib/db.js:6:19)
14:32:46 api | at Module._compile (internal/modules/cjs/loader.js:1151:30)
14:32:46 api | at Module._compile (/Users/tobias/Library/Mobile Documents/com~apple~CloudDocs/Web/redwoodblog/node_modules/pirates/lib/index.js:99:24)
14:32:46 api | at Module._extensions..js (internal/modules/cjs/loader.js:1171:10)
14:32:46 api | at Object.newLoader [as .js] (/Users/tobias/Library/Mobile Documents/com~apple~CloudDocs/Web/redwoodblog/node_modules/pirates/lib/index.js:104:7)
14:32:46 api | at Module.load (internal/modules/cjs/loader.js:1000:32)
14:32:46 api | at Function.Module._load (internal/modules/cjs/loader.js:899:14)
14:32:46 api | at Module.require (internal/modules/cjs/loader.js:1040:19)
14:32:46 api | at require (internal/modules/cjs/helpers.js:72:18)
error Command failed with exit code 1.
info Visit [https://yarnpkg.com/en/docs/cli/run](https://yarnpkg.com/en/docs/cli/run) for documentation about this command.
14:32:46 api | cd /Users/tobias/Library/Mobile\ Documents/com~apple~CloudDocs/Web/redwoodblog/api && yarn dev-server exited with code 1

@TurboTobias Thank you for this and I’ll dig in. The current Redwood release uses Prisma preview.025. We have Prisma beta.2 working in our ‘master’ but yet to be released — my current working theory is that the fix is in there.

re: Global Prisma install: Ah, this could definitely be part of the issue. Did you install globally prior to trying out Redwood? Or in attempt to get things working with Redwood?

Looking forward to the release :)

Yes, most likely I had the Prisma2 CLI (alpha version) installed prior to trying out Redwood the first time. But same result after uninstalling npm uninstall -g @prisma/cli --save, but not sure if that cleans everything? I did clear the rm -rf ~/.cache/prisma also with same results.

@thedavidprice I can also still reproduce the issue following the steps you listed. I also had the Prisma2 CLI installed globally before trying out Redwood, so it sounds like that may be the issue. I tried uninstalling the CLI, but it doesn't fix the issue. Also I'm on a Mac, not sure if that makes a difference.

Looking forward to the release :)

Me too!

Could you run the following and let us know if it generates the client, and migrates the database?

cd <myproject>/api
yarn prisma2 migrate up --experimental --create-db
yarn prisma2 generate

This is equivalent to what is run when you type yarn rw db up

  1. Running$ yarn prisma2 migrate up --experimental --create-db (from /api) errors the following
yarn run v1.21.1
$ '/Users/tobias/Library/Mobile Documents/com~apple~CloudDocs/Web/redwoodblog/node_modules/.bin/prisma2' migrate up --experimental --create-db
Error: Get config {"is_panic":false,"message":"error: Environment variable not found: BINARY_TARGET.\n  -->  schema.prisma:8\n   | \n 7 |   provider      = \"prisma-client-js\"\n 8 |   binaryTargets = env(\"BINARY_TARGET\")\n   | \n\nValidation Error Count: 1","meta":{"full_error":"error: Environment variable not found: BINARY_TARGET.\n  -->  schema.prisma:8\n   | \n 7 |   provider      = \"prisma-client-js\"\n 8 |   binaryTargets = env(\"BINARY_TARGET\")\n   | \n\nValidation Error Count: 1"},"error_code":"P1012"}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Same error for yarn prisma2 generate 👆

Tried yarn rw db up for funsies and it migrates the database but fails to set up client, "cannot call write after stream was destroyed".

Output

tobias@Tobiass-MacBook-Pro api % yarn rw db up
yarn run v1.21.1
$ '/Users/tobias/Library/Mobile Documents/com~apple~CloudDocs/Web/redwoodblog/node_modules/.bin/rw' db up
Migrate database up... [started]
$ '/Users/tobias/Library/Mobile Documents/com~apple~CloudDocs/Web/redwoodblog/node_modules/.bin/prisma2' migrate up --experimental --create-db
🏋️‍  migrate up

All migrations are already applied
Migrate database up... [completed]
Generating the Prisma client... [started]
$ '/Users/tobias/Library/Mobile Documents/com~apple~CloudDocs/Web/redwoodblog/node_modules/.bin/prisma2' generate
Error: Cannot call write after a stream was destroyed
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Generating the Prisma client... [failed]
→ Command failed with exit code 1: yarn prisma2 generate
Command failed with exit code 1: yarn prisma2 generate
✨  Done in 3.65s.

@TurboTobias Crazy, could you check that your .env.defaults has the BINARY_TARGETS line:

https://github.com/redwoodjs/create-redwood-app/blob/master/.env.defaults#L7

Yup, file matches exactly

# These environment variables will be used by default if you do not create any
# yourself in .env. This file should be safe to check into your version control
# system. Any custom values should go in .env and .env should *not* be checked
# into version control.

DATABASE_URL=file:./dev.db
BINARY_TARGET=native

Thanks, this gives me an idea! I'll get back to you soon

Just out of curiosity, how is yarn prisma2 ... supposed to work without any prisma2 command? I can't seem to find it in any of the package.json's or in the @redwoodjs repo

Check node_modules/.bin

~/Downloads/redwoodblog
➜ ls node_modules/.bin/prisma2
node_modules/.bin/prisma2

The package is installed here:
https://github.com/redwoodjs/redwood/blob/607e481626c9516ff07c18a57a66a6b424d89c52/packages/core/package.json#L20

@TurboTobias So I actually forgot how the yarn rw db generate command works 🤦‍♂️. It loads in the environmental variables defined in `.env:
https://github.com/redwoodjs/redwood/blob/db1dbbe41100de8edbadf434ae6cc2ed20f637f6/packages/cli/src/index.js#L8-L12

and then passes them in scope to the executed CLI:
https://github.com/redwoodjs/redwood/blob/8d510dbfb3c4c88c0d6448a9d58771a8eef547d7/packages/cli/src/lib/index.js#L196

Could you just run yarn rw db generate?

Yes, yarn rw db generate produces

tobias@Tobiass-MacBook-Pro redwoodblog % yarn rw db generate
yarn run v1.21.1
$ '/Users/tobias/Library/Mobile Documents/com~apple~CloudDocs/Web/redwoodblog/node_modules/.bin/rw' db generate
Generating the Prisma client... [started]
$ '/Users/tobias/Library/Mobile Documents/com~apple~CloudDocs/Web/redwoodblog/node_modules/.bin/prisma2' generate
Error: Cannot call write after a stream was destroyed
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Generating the Prisma client... [failed]
→ Command failed with exit code 1: yarn prisma2 generate
Command failed with exit code 1: yarn prisma2 generate
✨  Done in 3.28s.

Hi @TurboTobias,

See this issue: https://github.com/prisma/prisma/issues/1973
From your console output here it seems that the path Mobile Documents includes space. I suggest trying from a new system path

The “space in path” issue above is _very_ helpful. But this doesn’t seem to be the case for the OP @AndrewSverdrup (make sure to click the details hide/reveal): https://github.com/redwoodjs/redwood/issues/404#issue-596316604

There are a couple other data points for diagnosing:

We have a yarn rw info command, which uses envinfo package. Potentially we could add a check here for globally installed packages. However, since we use yarn it won’t pick up npm installed global packages. (Based on my local tests.)

As of now, I think 2/3 of the reported errors will resolve once we release new Redwood packages that include the latest Prisma beta. (Hopefully this Monday 🤞 )

Hi @TurboTobias,

See this issue: prisma/prisma#1973
From your console output here it seems that the path Mobile Documents includes space. I suggest trying from a new system path

Early on I looked at that issue and thought "I don't have spaces in my paths"... 🤦 But totally forgot that the Mac OS 10.15.* update raped my filesystem. It put common folders like Documents and similar undeneath this new "Mobile Documents" folder which is iCloud. So possible that others on recent Mac OS versions may experience the same.

Anyways, now the client is generated and everything is working (using another path without spaces) ✅

Thanks! 🙏

The space in the path was my issue too. I didn't realize that could be the cause of the issue and I sort of "sanitized" the path in the output logs I posted since the path to my project was fairly long. Never thought that'd be the issue 🤦. Thanks for the fix and I've learned not to modify the output log at all (seems obvious now 😅).

The space in the path was my issue too. I didn't realize that could be the cause of the issue and I sort of "sanitized" the path in the output logs I posted since the path to my project was fairly long. Never thought that'd be the issue 🤦. Thanks for the fix and I've learned not to modify the output log at all (seems obvious now 😅).

That is so funny that you made the path pretty. I did _exactly_ the same in my first log reply, thankfully I added more without modifying. Never again!

Looks like a fix is now merged into prisma/cli@alpha and will be in next Beta release:
https://github.com/prisma/prisma/issues/1973

This was reported earlier on Windows. Linking to test as well once next Prisma release is out and in RWJS: https://github.com/redwoodjs/redwood/issues/409

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jeliasson picture jeliasson  ·  3Comments

weaversam8 picture weaversam8  ·  3Comments

slavakurilyak picture slavakurilyak  ·  4Comments

thedavidprice picture thedavidprice  ·  3Comments

zwl1619 picture zwl1619  ·  3Comments