node-casbin: Class extends value undefined is not a constructor or null

When importing casbin in a typescript project for Angular I get this error: image

For the Model class I’ve solved by importing like this:

import { Model } from "casbin/lib/esm/model";

But for newEnforcer there is no way to work around that issue. Am I missing something?

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 26 (13 by maintainers)

Most upvoted comments

Hello @giovanni-bertoncelli, casbin.js@next has been released on NPM, you can use yarn add casbin.js@next or npm install casbin.js@next --save to add this to your project, how to use:

import { newEnforcer, newModel, MemoryAdapter } from 'casbin.js';

const model = newModel(`
[request_definition]
r = sub, obj, act

[policy_definition]
p = sub, obj, act

[role_definition]
g = _, _

[policy_effect]
e = some(where (p.eft == allow))

[matchers]
m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act
`);

const adapter = new MemoryAdapter(`
p, alice, data1, read
p, bob, data2, write
p, data2_admin, data2, read
p, data2_admin, data2, write

g, alice, data2_admin
`);


const enforcer = await newEnforcer(model, adapter);

Maybe this can be a valid alternative: https://www.papaparse.com/

@ghaiklor We are removing the dependency on csv-parse.But we are still discussing on the implementation of some standards

@giovanni-bertoncelli Once the new version is released, I will ping you.

@giovanni-bertoncelli Plz view casbin.js at v1 branch. casbin.js is under a totally refactor and will have the exactly funtion like node-casbin, but platform independent.