Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

94
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!