vuelidate icon indicating copy to clipboard operation
vuelidate copied to clipboard

Cannot convert undefined or null to object when build "vite": "^4.0.4",

Open stillgg opened this issue 2 years ago • 7 comments

when I build the project with vue 2.7.14 vite v4, i have an error if i run dev I don't have this problem

To Reproduce

  1. yarn build
  2. yarn preview

Screenshot 2023-03-06 at 15 56 17

Screenshot 2023-03-06 at 15 59 54

package.json Screenshot 2023-03-06 at 16 02 30

vite.config.ts

import {defineConfig, loadEnv} from 'vite'
import eslintPlugin from 'vite-plugin-eslint'
import {VuetifyResolver} from 'unplugin-vue-components/resolvers'
import {fileURLToPath, URL} from 'node:url'
import vue from '@vitejs/plugin-vue2'
import components from 'unplugin-vue-components/vite'

export default defineConfig(({mode}) => {
  process.env = {...process.env, ...loadEnv(mode, process.cwd(), '')}

  return {
    plugins: [
      vue(),
      eslintPlugin(),
      components({
        resolvers: [VuetifyResolver()],
      }),
    ],
    resolve: {
      alias: {
        '@': fileURLToPath(new URL('./src', import.meta.url)),
      },
      extensions: ['.js', '.json', '.jsx', '.mjs', '.ts', '.tsx', '.vue'],
    },
    css: {
      preprocessorOptions: {
        sass: {
          additionalData: ['@import "./src/scss/variables"', ''].join('\n'),
        },
      },
    },
    define: {
      'process.env': process.env,
    },
    server: {
      port: 3000,
      host: true,
    },
  }
})

stillgg avatar Mar 06 '23 13:03 stillgg

it doesn't work import {required} from 'vuelidate/lib/validators'

but it work's well import required from 'vuelidate/lib/validators/required'

why does it happen?

stillgg avatar Mar 06 '23 13:03 stillgg

@stillgg, It looks like you are using an outdated Vuelidate version.

Correct path: import { required } from "@vuelidate/validators";

lermontex avatar Mar 11 '23 21:03 lermontex

@stillgg, It looks like you are using an outdated Vuelidate version.

Correct path: import { required } from "@vuelidate/validators";

my version of vuelidate : "vuelidate": "^0.7.7" it's the last version for vue 2

stillgg avatar Mar 12 '23 10:03 stillgg

Both versions (Vue 2/ Vue 3) are supported according to the documentation.

lermontex avatar Mar 12 '23 11:03 lermontex

I don't find this information can you share this link of docs

stillgg avatar Mar 12 '23 14:03 stillgg

https://github.com/vuelidate/vuelidate/blob/next/README.md#vuelidate

lermontex avatar Mar 12 '23 16:03 lermontex

thanks a lot

stillgg avatar Mar 13 '23 08:03 stillgg