Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codesandbox: Cannot find module 'rxjs' or its corresponding type declarations.ts(2307) #6530

Closed
laurencefass opened this issue Jul 20, 2021 · 4 comments

Comments

@laurencefass
Copy link

laurencefass commented Jul 20, 2021

Bug Report

I can see a couple of threads related to this but none of them solve it and they are also closed. This refers specifically to version 7.2.0 I cant import rxjs module in a very basic example. Ive tried changing versions to 6.6.3 but then i can import rxjs/operators. The import system appears to be a unstable and possibly not backward compatible.

Current Behavior
version 7.2

import { interval } from 'rxjs'; 

results in an error:

Codesandbox: Cannot find module 'rxjs' or its corresponding type declarations.ts(2307)

changing to version 6.6.3 fixes the above error and produces the same error for rxjs/operators

Expected behavior
should not be an error

Reproduction
https://codesandbox.io/s/redux-hooks-observables-uxyvq?file=/src/Epics/epics.ts:0-32

import { interval } from 'rxjs'; // <== cant import rxjs!
import { mapTo, delay, tap } from 'rxjs/operators';
import { ofType } from "redux-observable";
import { INCREMENT, DECREMENT, pongAction, multiplyAction } from "../Actions/actions"

export const pingEpic = action$ =>
  action$.pipe(
    ofType("PING"),
    tap(val => console.log(`pingEpic tap: ${JSON.stringify(val)}`)),
    delay(1000),
    mapTo(pongAction())
  );


export const counterEpic = action$ =>
  action$.pipe(
    ofType(INCREMENT, DECREMENT),
    tap(val => console.log(`counterEpic tap: ${JSON.stringify(val)}`)),
    delay(1000),
    // interval(1000),
    mapTo(multiplyAction(2))
  );

Environment

  • Runtime: Codesandbox
  • RxJS version: 7.2.0
  • (If bug is related) Loader, build configuration: [e.g webpack, angular-cli version, config]

Possible Solution

Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.

@laurencefass
Copy link
Author

not sure why changing versions a few times removed the errors. not reproducible.

@kasir-barati
Copy link

kasir-barati commented Jan 18, 2022

I got the same error even due the rxjs is installed. My tsconfig.json:

{
    "compilerOptions": {
        "module": "commonjs",
        "declaration": true,
        "removeComments": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "allowSyntheticDefaultImports": true,
        "target": "es2017",
        "sourceMap": true,
        "outDir": "./dist",
        "baseUrl": "./",
        "incremental": true,
        "skipLibCheck": true,
        "strictNullChecks": false,
        "noImplicitAny": false,
        "strictBindCallApply": false,
        "forceConsistentCasingInFileNames": false,
        "noFallthroughCasesInSwitch": false,
        "paths": {
            "@src/*": ["src/*"]
        }
    }
}

Where I am importing the rxjs: "/src/shared/lib/some-file.ts"

rxjs version: 7.2.0
node version: 17.3.0
npm version: 8.3.0
OS: MX Linux

Solution:

update your version to npm i rxjs@7.5.2

@Rfluid
Copy link

Rfluid commented Nov 7, 2023

I got the same error with import { Observable } from 'rxjs';.
Versions:
npm: 9.8.0
node: v20.5.1
"node_modules/rxjs": { "version": "7.8.1", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.1.tgz", "integrity": "sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==", "dependencies": { "tslib": "^2.1.0" } },
my tsconfig:
{ "compilerOptions": { "module": "commonjs", "declaration": true, "removeComments": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "allowSyntheticDefaultImports": true, "target": "ES2021", "sourceMap": true, "outDir": "./dist", "baseUrl": "./", "incremental": true, "skipLibCheck": true, "strictNullChecks": false, "noImplicitAny": false, "strictBindCallApply": false, "forceConsistentCasingInFileNames": false, "noFallthroughCasesInSwitch": false, "paths": { "@/*": ["src/*"] } } }

@HiptJo
Copy link

HiptJo commented Jan 10, 2024

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants