Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

1.1K
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda