casl
casl copied to clipboard
vue nuxt3 esbuild error
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)
can you create isolated repo with this issue?
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 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.