question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot add any custom directive (locally or globally)

See original GitHub issue

Environment

  • Operating System: Darwin
  • Node Version: v16.13.0
  • Nuxt Version: 3.0.0-27277498.850ef69
  • Package Manager: npm@8.1.0
  • Bundler: Vite
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Describe the bug

It’s impossible to add any custom directive (locally or globally).

I get this: [SSR] Error transforming /Users/Me/Desktop/nuxt3-app/pages/index.vue: SyntaxError: Custom directive is missing corresponding SSR transform and will be ignored.

Reproduction

https://codesandbox.io/s/elastic-frog-4c8fr?file=/pages/index.vue

Additional context

No response

Logs

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9

github_iconTop GitHub Comments

5reactions
speedyviccommented, Dec 9, 2021

Hi.

Adding the patch from this post patch-vue-directive-ssr solved the issue with styleclass/ripple primevue directives. Helmes, please try, hope it works for you as well. Do not forget to remove the vue compilerOptions from nuxt.config.

Boomer! Started experiencing Vue Hydration Node Mismatchs. Perhaps the patch uncover something I’m doing wrong. Update: The Node Mismatchs are being created by Toast.

3reactions
andysaycommented, Dec 2, 2021

I tried with your version. Still not working for me and neither on codesandbox.io…

in nuxt config try add this


import { defineNuxtConfig } from 'nuxt3'

export default defineNuxtConfig({
  vue: {
    compilerOptions: {
      directiveTransforms: {
        focus: () => ({
          props: [],
          needRuntime: true
        })
      }
    }
  }
})

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I define a custom directive using composition API in ...
Use the directive in the component's template like <div my-directive></div> . Preferably without having to add boilerplate like registering the ...
Read more >
Custom Directives | Vue.js
Similar to components, custom directives must be registered so that they can be used in templates. In the example above, we are using...
Read more >
Creating Your First Vue Custom Directive - with Vue 3 Updates
A Vue custom directive is, as you may guess, Vue's way of letting us build additional directives for our projects.
Read more >
A deep dive into custom Vue directives - LogRocket Blog
Using the cloneNode and prepend JavaScript functions of the Web API, it is simple to copy a node and add it to an...
Read more >
Custom Directives in Vue JS - This Dot Labs
To register a custom directive locally, navigate to the component where you want to use the custom directive, and add the method below...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found