1

I'm new to nuxtjs and I'm trying to import a vue component to nuxt.

I'm using vuetify on my project, and I want to use this plugin https://vuejsexamples.com/date-range-picker-for-vuetify-js/ which is a daterange-picker.

I've added the component using npm.

My nuxt.config.js looks like this :

...

// Global CSS (https://go.nuxtjs.dev/config-css)
css: [
  { src: '~/node_modules/vuetify-daterange-picker/dist/vuetify-daterange-picker.css' }
],

// Plugins to run before rendering page (https://go.nuxtjs.dev/config-plugins)
plugins: [

],

// Auto import components (https://go.nuxtjs.dev/config-components)
components: true,

// Modules for dev and build (recommended) (https://go.nuxtjs.dev/config-modules)
buildModules: [
  // https://go.nuxtjs.dev/eslint
  //'@nuxtjs/eslint-module',
  // https://go.nuxtjs.dev/vuetify
  '@nuxtjs/vuetify',
  '~/node_modules/vuetify-daterange-picker'
],

// Modules (https://go.nuxtjs.dev/config-modules)
modules: [
  // https://go.nuxtjs.dev/axios
  '@nuxtjs/axios',
  // https://go.nuxtjs.dev/pwa
  '@nuxtjs/pwa',
  // https://go.nuxtjs.dev/content
  '@nuxt/content',
],

// Axios module configuration (https://go.nuxtjs.dev/config-axios)
axios: {},

// Content module configuration (https://go.nuxtjs.dev/config-content)
content: {},
...

When I run my project I've got this error in the browser Browser Error

And this error in the terminal Terminal Error

0

1 Answer 1

2

Don't import manually the component from "node_modules".

You have to create a new Nuxt "plugin" to import and init your vue component in Nuxt:

// plugins/your-component.js

import VuetifyDaterangePicker from "vuetify-daterange-picker";
import "vuetify-daterange-picker/dist/vuetify-daterange-picker.css";

Vue.use(VuetifyDaterangePicker);
// nuxt.config.js

export default {
  plugins: ['~/plugins/your-component.js'],
  // ...
}

see docs: https://nuxtjs.org/docs/2.x/directory-structure/plugins#vue-plugins


Another way is to use the nuxt vuetify-module: https://github.com/nuxt-community/vuetify-module

Sign up to request clarification or add additional context in comments.

2 Comments

I've tried this as well but I get the same issue.
We need more details to understand your error at this step. Can you share your project on github or codesandbox to reproduce the issue and check your source code?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.