casl icon indicating copy to clipboard operation
casl copied to clipboard

vue nuxt3 esbuild error

Open jorgv opened this issue 2 years ago • 2 comments

Hello,

Thanks for such great library.

Using a new Nuxt3 instance and adding the vue casl plugin, throws the following esbuild error:

import { defineNuxtPlugin } from '#app';
import { abilitiesPlugin } from '@casl/vue';
import { Ability } from '@casl/ability';

export default defineNuxtPlugin((nuxtApp) => {
  const ability = new Ability();
  nuxtApp.vueApp.use(abilitiesPlugin, ability, {
    useGlobalProperties: true,
  });
});

[nuxt] [request error] [unhandled] [500] Cannot set property $ability of #<Object> which has only a getter
  at a (./node_modules/.pnpm/@[email protected]_2pnb2rzpnfnooo3ffg7mi6xtha/node_modules/@casl/vue/dist/es6m/index.mjs:1:1498)  

jorgv avatar Aug 23 '22 14:08 jorgv

can you create isolated repo with this issue?

stalniy avatar Aug 24 '22 03:08 stalniy

Hello @stalniy thanks for your answer, trying to replicate the repo I realized I had in the layout this line:

this.$ability.update(abilities);

From a previous version, it seems like this changed or it's failing. You can close this by commenting on this line, the error is gone.

jorgv avatar Aug 25 '22 20:08 jorgv

@jorgv could you get your nuxt3 app working with casl? I am a bit struggling with setting up the plugin and and updating the abilityFor a new user when logging in.

Could you provide a minimal example of your nuxt3-casl app.

Thanks in advance.

andorfermichael avatar Oct 18 '22 05:10 andorfermichael