Vee-validate: Error: "export 'default' (imported as 'VeeValidate') was not found in 'vee-validate'

Created on 25 Aug 2019  路  9Comments  路  Source: logaretm/vee-validate

Versions

  • vee-validate: 3.0.0
  • vue: 2.6

Describe the bug
I am getting this error:
"export 'default' (imported as 'VeeValidate') was not found in 'vee-validate'

My main.js

```
// VeeValidate
import VeeValidate from 'vee-validate';
import { ValidationProvider} from 'vee-validate';
import ValidationMessage from "@/views/shared/ValidationMessage";
Vue.component('ValidationProvider', ValidationProvider);
Vue.component('ValidationObserver', ValidationObserver);
Vue.component('ValidationMessage', ValidationMessage);
Vue.use(VeeValidate, {
inject: true,
fieldsBagName: '$veeFields',
errorBagName: '$veeErrors'
})

Also

Most helpful comment

To solve:
import * as VeeValidate from 'vee-validate';

All 9 comments

To solve:
import * as VeeValidate from 'vee-validate';

VeeValidate 3.0 no longer needs to be installed by Vue, and thus it doesn't have any default exports.

So these lines are not doing anything at all:

Vue.use(VeeValidate, {
  inject: true,
  fieldsBagName: '$veeFields',
  errorBagName: '$veeErrors'
})

make sure to read the documentation as a lot has changed.

I tried all ways man. So I switched to 2.1.5
Also this error exists on your demos..

If I switch to 3.0.0 gets this error:
No such validator 'required' exists.

VeeValidate 3.0 introduced a lot of breaking changes, you should not migrate older projects if they depend heavily on v-validate directive.

You can find the changes detailed here #2222

Actually it's new project and there is no v-validate directive.

Ok great, that should make it easier to upgrade.

To sum it up for you, the breaking changes are:

  • All rules have been excluded from the main bundle.
  • There is no default export, so you can't use import VeeValidate from 'vee-validate';
  • Validator and Error Bag no longer exist, use validate function instead.
  • Messages signature has been changed and a new i18n system has been introduced.

Again all of this is documented in #2222

If you have a look in the vee-validate files (eg node_modules/vee-validate/dist/vee-validate.js) you can see what gets exported. I'm using v3.3.0 and it says the following:

exports.ValidationObserver = ValidationObserver;
exports.ValidationProvider = ValidationProvider;
exports.configure = configure;
exports.extend = extend;
exports.localeChanged = localeChanged;
exports.localize = localize;
exports.normalizeRules = normalizeRules;
exports.setInteractionMode = setInteractionMode;
exports.validate = validate;
exports.version = version;
exports.withValidation = withValidation;

So if i want to be able to call the localize function then i can import it as:

import { localize } from 'vee-validate';

This way you dont have to import everything, just what you need.

To solve:
import * as VeeValidate from 'vee-validate';

This worked for me, thanks a lot!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

YamenSharaf picture YamenSharaf  路  3Comments

biapar picture biapar  路  3Comments

saintplay picture saintplay  路  3Comments

the94air picture the94air  路  3Comments

yyyuuu777 picture yyyuuu777  路  3Comments