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

95
Vistas
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 Respuestas
Responde la pregunta

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 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