Skip to content

SyntaxError: Cannot use import statement outside a module #4945

Closed as not planned
@boboldehampsink

Description

@boboldehampsink

What happened?

Since 4.14.4 (specifically 4f88d85) I see this error when running my tests:

    /Users/boboldehampsink/Work/Robuust/zsm-brigante/node_modules/vee-validate/dist/vee-validate.mjs:6
    import { getCurrentInstance, inject, warn as warn$1, computed, toValue, ref, watch, nextTick, unref, isRef, reactive, onUnmounted, onMounted, provide, onBeforeUnmount, defineComponent, toRef, resolveDynamicComponent, h, readonly, watchEffect, shallowRef } from 'vue';
    ^^^^^^

    SyntaxError: Cannot use import statement outside a module

      27 | } from '@ionic/vue';
      28 |
    > 29 | import { defineRule } from 'vee-validate';
         | ^
      30 | import { required, min_value, numeric, email } from '@vee-validate/rules';
      31 |
      32 | config.global.mocks.$t = (key, params = null) => key;

      at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1728:14)
      at Object.<anonymous> (tests/unit/index.js:29:1)

Reproduction steps

  1. Use 4.14.4 or higher
  2. Use Jest and add an index.js file, with in there: import { defineRule } from 'vee-validate';
  3. Run jest

Version

Vue.js 3.x and vee-validate 4.x

What browsers are you seeing the problem on?

  • Firefox
  • Chrome
  • Safari
  • Microsoft Edge

Relevant log output

No response

Demo link

no

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions