Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Unexpected token export" when importing validation rules in Nuxt.js #2240

Closed
chrislentz opened this issue Aug 27, 2019 · 6 comments
Closed

Comments

@chrislentz
Copy link
Contributor

Versions

  • vee-validate: 3.0.2
  • vue: 2.6.10
  • nuxt: 2.9.1

Describe the bug
When I try to import the "required" rule inside a Nuxt.js plugin, I am receiving a Unexpected token export error. If I comment out the "required" import or the "required" extend lines, the issue go away.

Customer Nuxt.js Plugin Code

import Vue from 'vue';
import { ValidationProvider, extend, configure } from 'vee-validate';
import { required } from 'vee-validate/dist/rules';

extend('required', required);

configure({
  classes: {
    invalid: 'is-danger'
  }
});

Vue.component('ValidationProvider', ValidationProvider);
@HEXLAB-KODAMA
Copy link

I don't know why...for now

nuxt.config.js

module.exports = {
  build: {
    transpile: [
      'vee-validate'
    ]
  }
}

@oritwoen
Copy link

Everything is thoroughly explained in documentation, including the error that occurs and the correct integration.

Link: https://baianat.github.io/vee-validate/examples/nuxt.html

@logaretm
Copy link
Owner

Thank you @ririen for linking the documentation. Closing...

@raapperez
Copy link

raapperez commented Nov 11, 2019

@ririen The link doesn't work anymore.

Also found this one: https://logaretm.github.io/vee-validate/examples/nuxt.html

@danirod
Copy link

danirod commented Nov 27, 2019

Both links are broken at the moment. I've done my homework and researched the solution in the project history. Adding the solution here because links cannot be trusted.

"vee-validate/dist/rules" needs to be added to the transpile item in the build key of the nuxt.config.js file.

  build: {
    // Add exception
    transpile: [
      "vee-validate/dist/rules"
    ],
    /*
     ** You can extend webpack config here
     */
    extend(config, ctx) {}
  }

@logaretm
Copy link
Owner

The docs were re-structured recently, there is the new link:

https://logaretm.github.io/vee-validate/guide/rules.html#importing-rules-in-nuxt-js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants