Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find module 'src/app/services/session.response' or its corresponding type declarations

Tags:

angular

ngxs

I have upload my project Angular on Stackblitz, the project works perfectly on Visual Studio Code.

But, when I open the project on Stackblitz, I have an error message:

Error in src/app/store/session/session.actions.ts (1:32)
Cannot find module 'src/app/services/session.response' or its corresponding type declarations.

I opened the session.action.ts file:

import { SessionReponse } from "src/app/services/session.response";

export class SessionAction {
    static readonly type = '[login] connexion';
    constructor(public session: SessionReponse ) { }
}

I don't understand where comes the problem, because I have the same code on Visual Studio Code.

My project on Stackblitz is here.

Thanks you very much for your help.

like image 283
aagharaf Avatar asked Apr 17 '26 04:04

aagharaf


1 Answers

Don't use absolute paths like from "src/app/services/session.response"; as typescript will try to locate a module, which has much to do with how you have typescript configured in tsconfig.json

You should use relative to your project paths for components that belong to the current project. Check this in your project and you will see that the error will be eliminated

import { SessionReponse } from '../../services/session.response';

Absolute paths are recognized as modules which should exist under node_modules/.

like image 100
Panagiotis Bougioukos Avatar answered Apr 18 '26 22:04

Panagiotis Bougioukos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!