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

99
Visualizações
Rx.Observable.from is not a function

I started learning reactive programming in javascript using RxJS and it's my first time using node. I don't exactly know what I'm doing wrong. Here is the code:

const array = [
    '1', 'Max', '2', '3', '4', '5', 'IoT', '6', '7', '8', '9'
];

const stream = Rx.Observable.from(array);

This is the error:

TypeError: Rx.Observable.from is not a function

This is what I've tried so far:

I've installed RxJS using node install rxjs, nothing else. I've tried importing from directly using import:

import { from } from 'rxjs';

When I've tried importing from using import, I've gotten this error:

SyntaxError: Cannot use import statement outside a module.

I've tried to go in the package-lock.json file and add the type of the module to module, but I've gotten the same error:

This is what I've tried doing to the package-lock.json file:

{
  "requires": true,
  "lockfileVersion": 1,
  "dependencies": {
    "rxjs": {
      "version": "7.4.0",
      "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.4.0.tgz",
      "integrity": "sha512-7SQDi7xeTMCJpqViXh8gL/lebcwlp3d831F05+9B44A4B0WfsEwUQHR64gsH1kvJ+Ep/J9K2+n1hVl1CsGN23w==",
      "requires": {
        "tslib": "~2.1.0"
      },
      "type": "module"
    },
    "tslib": {
      "version": "2.1.0",
      "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.1.0.tgz",
      "integrity": "sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A==",
      "type": "module"
    }
  }
}

Sources:

Cannot use import statement outside a module...

fromArray is deprecated, use from

The question is :

How can I use from in RxJS

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Your import syntax seems correct, One shouldn't temper XXXX.lock.json file as its strictly for package management purpose. May be this codeSandbox link could help you understand issue in your setup.

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