node-casbin / prisma-adapter

Prisma adapter for Casbin
Apache License 2.0
31 stars 18 forks source link

Cannot install with Prisma 2.21.1 #22

Closed Jack-Barry closed 3 years ago

Jack-Barry commented 3 years ago

When trying to install casbin-prisma-adapter on a fresh project, I'm hit with the following error output from Prisma:

npm ERR! code 1
npm ERR! path /Users/jack_barry/repos/playground-prisma/node_modules/@prisma/cli
npm ERR! command failed
npm ERR! command sh -c node scripts/preinstall-entry.js
npm ERR! ┌─────────────────────────────────────────────────────────────────────────────┐
npm ERR! │                                                                             │
npm ERR! │     The package @prisma/cli has been renamed to prisma.                     │
npm ERR! │                                                                             │
npm ERR! │     Please uninstall @prisma/cli first.                                     │
npm ERR! │     Then install prisma to continue using Prisma CLI:                       │
npm ERR! │                                                                             │
npm ERR! │         # Uninstall old CLI                                                 │
npm ERR! │         npm uninstall @prisma/cli                                           │
npm ERR! │                                                                             │
npm ERR! │         # Install new CLI                                                   │
npm ERR! │         npm install prisma --save-dev                                       │
npm ERR! │                                                                             │
npm ERR! │         # Invoke via npx                                                    │
npm ERR! │         npx prisma --help                                                   │
npm ERR! │                                                                             │
npm ERR! │     Learn more here: https://github.com/prisma/prisma/releases/tag/2.16.0   │
npm ERR! │                                                                             │
npm ERR! └─────────────────────────────────────────────────────────────────────────────┘

I think that the dependency of @prisma/cli is causing this.

If I try to install @prisma/cli directly it gives similar errors. This happens because of the preinstall.js script that gets run as part of the preinstall script from the package.json of @prisma/cli

Have confirmed that if I build and pack casbin-prisma-adapter locally after removing the peerDependency of @prisma/cli, the issue is no longer present on install. Would removing that as a peerDependency be particularly harmful?

hsluoyz commented 3 years ago

@Zxilly

Zxilly commented 3 years ago

Thanks!

hsluoyz commented 3 years ago

@Jack-Barry @Zxilly can we just update the @prisma/cli pkg to latest version to fix this issue?

Jack-Barry commented 3 years ago

@hsluoyz It looks like the latest version of the @prisma/cli package includes the preinstall script that prevents it from being installed, to guide users to installing the prisma package instead. So if anything the version of @prisma/cli would probably have to be locked at an older version to continue using/installing it.

It looks like the fix proposed in #23 does what's needed (switches the dependency/peerDependency to prisma)

hsluoyz commented 3 years ago

@Jack-Barry released: https://www.npmjs.com/package/casbin-prisma-adapter/v/1.0.2

Jack-Barry commented 3 years ago

@hsluoyz That worked a treat, thanks for the quick update and release