Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

372
Vistas
Process.env undefined in vite

I trying to use Tesserract.js https://github.com/naptha/tesseract.js#documentation with Vue.js which uses Vite as bundler.

My problem is that I get this error:

Cannot read properties of undefined (reading 'TESS_ENV')

This error happens inside:

module.exports = {
  ...defaultOptions,
  workerPath: (typeof process !== 'undefined' && process.env.TESS_ENV === 'development')
    ? resolveURL(`/dist/worker.dev.js?nocache=${Math.random().toString(36).slice(3)}`)
    : `https://unpkg.com/tesseract.js@v${version}/dist/worker.min.js`,
  /*
   * If browser doesn't support WebAssembly,
   * load ASM version instead
   */
  corePath: `https://unpkg.com/tesseract.js-core@v${dependencies['tesseract.js-core'].substring(1)}/tesseract-core.${typeof WebAssembly === 'object' ? 'wasm' : 'asm'}.js`,
};

Well, in vite I need to use import.meta.env.MODE instead of process.env.TESS_ENV

I tried to change the tesseract.js code. I went inside:

node_modules -> tesseract -> src -> worker -> browser -> defaultOptions.js

And changed it to import.meta.env.MODE but for some reason the code does not get applied and it still displays me the old error.

How do I make this work?

about 4 years ago · Santiago Gelvez
2 Respuestas
Responde la pregunta

0

I got it:

export default defineNuxtConfig({
  vite: {
    define: {
      "process.env.TESS_ENV": process.env.ENV,
    },
  },
});

I need to defined it, now its not undefined anymore

about 4 years ago · Santiago Gelvez Denunciar

0

Remember to use the correct prefixes for .env file used in Vite, Nuxt etc. ex.:

for Vite

VITE_BASE_URL: 'example.com'

for Nuxt3

NUXT_BASE_URL: 'example.com'

OR

define it straight inside defineNuxtConfig

about 4 years ago · Santiago Gelvez Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda