zenstackhq / zenstack

Fullstack TypeScript toolkit that enhances Prisma ORM with flexible Authorization layer for RBAC/ABAC/PBAC/ReBAC, offering auto-generated type-safe APIs and frontend hooks.
https://zenstack.dev
MIT License
2.07k stars 88 forks source link

npx zenstack@latest init broken (TypeError: Class extends value undefined is not a constructor or null) #379

Closed devx-opensource closed 1 year ago

devx-opensource commented 1 year ago

Description and expected behavior npx zenstack@latest init should work but instead got this:

_npx/aded272cd7beac82/node_modules/chevrotain-allstar/lib/all-star-lookahead.js:62 class LLStarLookaheadStrategy extends chevrotain_1.LLkLookaheadStrategy { ^

TypeError: Class extends value undefined is not a constructor or null at Object. (/Users/sam/.npm/_npx/aded272cd7beac82/node_modules/chevrotain-allstar/lib/all-star-lookahead.js:62:52) at Module._compile (node:internal/modules/cjs/loader:1254:14) at Module._extensions..js (node:internal/modules/cjs/loader:1308:10) at Module.load (node:internal/modules/cjs/loader:1117:32) at Module._load (node:internal/modules/cjs/loader:958:12) at Module.require (node:internal/modules/cjs/loader:1141:19) at require (node:internal/modules/cjs/helpers:110:18) at Object. (/Users/sam/.npm/_npx/aded272cd7beac82/node_modules/chevrotain-allstar/lib/index.js:9:28) at Module._compile (node:internal/modules/cjs/loader:1254:14) at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)

Node.js v18.15.0

Environment (please complete the following information):

Additional context Tried on a macbook M2, on an ubuntu machine, with NodeJS 16 & 18

ymc9 commented 1 year ago

Hi @devx-opensource ,

Thanks for reporting this. I tried to reproduce it by initializing a Next.js + Prisma project with the latest zenstack (1.0.0-alpha.113) with the following setups but couldn't see the failure:

I suspect it either has something to do with an outdated version dangling around or something specific with the project being initialized. Could you help me with the following information?

Thanks!

chunkerchunker commented 1 year ago

I ran into the same problem (Mac M1, Node 16/18, zenstack@alpha.11*). (I'm trying zenstack for the first time.)

My npx chevrotain-allstar version is 0.1.7.

Looking at the source, this requires chevrotain >= 10.0.0.

But my npx chevrotain is at 9.1.0.

It looks like the problem is that zenstack/package.json specifies chevrotain ^9.1.0 while it also specifies langium 1.1.0, which correctly requires chevrotain 10.4.2.

I was able to successfully run the 'zenstack init' from source at current master and verified that the correct version of chevrotain is used (10.4.2).

So I believe the fix is simply to remove the chevrotain dependency from zenstack/package.json.

ymc9 commented 1 year ago

Thanks for looking into this @chunkerchunker ! The dependency on chevrotain was added previously for avoiding a bug in its newer version ...

Let me remove that (and probably also upgrade to the new version of langium as well).

ymc9 commented 1 year ago

Hey @devx-opensource @chunkerchunker I've published a new version (alpha.116) for the fix.

chunkerchunker commented 1 year ago

Thanks for such a quick turnaround! I just verified that it works for me.

ymc9 commented 1 year ago

Awesome. Thank you!

ymc9 commented 1 year ago

Fixed by #407