Prisma: `prisma2 init` fails in Yarn Workspaces

Created on 20 Dec 2019  ·  3Comments  ·  Source: prisma/prisma

Problem

prisma2 init fails when the folder created is expected to be a workspace. It'd be ideal to have a Prisma project inside a monorepo.

Project tree

This is a simple example:

Directory structure

  • my-project/

    • .gitignore

    • package.json

.gitignore

node_modules

package.json

{
  "name": "my-project",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "private": true,
  "workspaces": [
    "my-project-api"
  ]
}

Error

The structure above fails:

❯ prisma2 init my-project-api

Preparing your starter kit: GraphQL API

✔  Downloading the starter kit from GitHub ...
✔  Extracting content to my-project-api ...
⠋  Installing dependencies with: `npm install` ...
4  Preparing your database ...
5  Seeding your database with: `npm run seed` ...
 ERROR  Error during command execution

warning package.json: No license field
warning Missing version in workspace at "/Users/rene/Development/my-project/my-project-api", ignoring.
Error:
    Error: In order to use the "photonjs" generator, you need to install @prisma/photon to your project:
    npm add @prisma/photon
        at /Users/rene/.config/yarn/global/node_modules/prisma2/build/index.js:260319:23
        at Generator.next (<anonymous>)
        at /Users/rene/.config/yarn/global/node_modules/prisma2/build/index.js:260297:71
        at new Promise (<anonymous>)
        at module.exports.9949.__awaiter (/Users/rene/.config/yarn/global/node_modules/prisma2/build/index.js:260293:1
2)
        at Object.photonjs (/Users/rene/.config/yarn/global/node_modules/prisma2/build/index.js:260312:37)
        at Object.<anonymous> (/Users/rene/.config/yarn/global/node_modules/prisma2/build/index.js:122670:114)
        at Generator.next (<anonymous>)
        at /Users/rene/.config/yarn/global/node_modules/prisma2/build/index.js:122587:71
        at new Promise (<anonymous>)
error Command failed with exit code 1.

Versions Used

Prisma

❯ prisma2 --version          
[email protected], binary version: e7579bd35e0938dbf773f1706c098a0d14a5a038

Yarn

❯ yarn --version
1.12.3

Node

❯ node --version                      
v12.8.1

NPM

❯ npm --version         
6.13.0

Similar Issues

These seem to be related:

bu2-confirmed kinbug cli-init

Most helpful comment

I can confirm this. First of all, we don't have a version property in the package.json that we generate so the yarn is ignoring that package which in turn doesn't allow us to install @prisma/photon. We need to fix this.

All 3 comments

I can confirm this. First of all, we don't have a version property in the package.json that we generate so the yarn is ignoring that package which in turn doesn't allow us to install @prisma/photon. We need to fix this.

The new non-interactive init CLI solves that issue.

So first update your prisma2 package to the latest, it should be version 2.0.0-preview020 (or use npx like below) then:

Thanks a lot for reporting 🙏
This issue is fixed in the latest alpha version of prisma2.
You can try it out with npm i -g prisma2@alpha.

In case it’s not fixed for you - please let us know and we’ll reopen this issue!

Was this page helpful?
0 / 5 - 0 ratings