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

1.1K
Vistas
TypeError: Class extends value undefined is not a constructor or null (svelte redis)

I just got started with svelte and was trying to make an app with redis as the db. I made a typescript file with all the db functions I would need and tried to import it into my svelte components, but when I did that I got the following error

Class extends value undefined is not a constructor or null
TypeError: Class extends value undefined is not a constructor or null
    at node_modules/@node-redis/client/dist/lib/client/socket.js (http://localhost:3000/node_modules/.vite/chunk-L35TFNQI.js?v=60c87e0f:6515:46)
    at __require (http://localhost:3000/node_modules/.vite/chunk-VP3FZ6LR.js?v=60c87e0f:25:44)
    at node_modules/@node-redis/client/dist/lib/client/index.js (http://localhost:3000/node_modules/.vite/chunk-L35TFNQI.js?v=60c87e0f:9192:20)
    at __require (http://localhost:3000/node_modules/.vite/chunk-VP3FZ6LR.js?v=60c87e0f:25:44)
    at node_modules/@node-redis/client/dist/index.js (http://localhost:3000/node_modules/.vite/redis.js?v=60c87e0f:852:20)
    at __require (http://localhost:3000/node_modules/.vite/chunk-VP3FZ6LR.js?v=60c87e0f:25:44)
    at node_modules/redis/dist/index.js (http://localhost:3000/node_modules/.vite/redis.js?v=60c87e0f:2589:20)
    at __require (http://localhost:3000/node_modules/.vite/chunk-VP3FZ6LR.js?v=60c87e0f:25:44)
    at http://localhost:3000/node_modules/.vite/redis.js?v=60c87e0f:2615:21

This is my redis file (even with only this much, I get the same error)

import redis from 'redis'

export var str = "sample string"

This is my svelte component's script

<script lang="ts">
    import { str } from "../redis_test";
</script>
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Normally, because the redis - npm package is designed for Node.js, I would say to follow How to use npm modules in browser? and use browserify so that it's able to run in the browser.

After reading Can I connect directly to a Redis server from JavaScript running in a browser?, I would say that you need a server-side setup to connect to your redis server and then you can query your server-side as you need.

about 4 years ago · Juan Pablo Isaza Denunciar

0

I've had a similar problem and my understanding from reading the above is that it caused because the browser client is trying to read the db which is on the server. I am also using sveltekit and I resolved by problem by making sure my code was in an endpoint, which only runs on the server and then invoked the endpoint to get my data.

about 4 years ago · Juan Pablo Isaza 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