flat-fuchsia
flat-fuchsia11mo ago

Cannot find module '@hooks' or its corresponding type declarations.

Hello everyone, I think many have encountered a similar error, please tell me what to do... ./node_modules/@refinedev/core/src/components/pages/login/index.tsx:3:40 Type error: Cannot find module '@hooks' or its corresponding type declarations. 1 | import React, { useState } from "react"; 2 | 3 | import { useLogin, useTranslate } from "@hooks"; | ^ 4 | import { useActiveAuthProvider } from "@definitions/helpers"; 5 | export interface ILoginForm { 6 | username: string;
9 Replies
kapa.ai
kapa.ai11mo ago
Hi @sonya. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The error message you're seeing is due to the fact that the module '@hooks' cannot be found. This could be because the '@hooks' alias is not correctly set up in your project, or the module does not exist. In the context of Refine, hooks are usually imported from the '@refinedev/core' package, not '@hooks'. For example, the useLogin and useTranslate hooks should be imported like this:
import { useLogin, useTranslate } from "@refinedev/core";
import { useLogin, useTranslate } from "@refinedev/core";
If you're working on the development of Refine itself, it's possible that the '@hooks' alias is set up in the project configuration. In this case, make sure you've bootstrapped the project correctly. You can refer to the contributing guide (https://refine.dev/docs/contributing/) for more information. If you're still having trouble, please provide more information about your environment and the steps you've taken so far. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai11mo ago
<@1205446785254948886> kapa.ai is still learning and improving, please let us know how it did by reacting below
flat-fuchsia
flat-fuchsiaOP11mo ago
@kapa.ai this error occurs in the refine/dev core itself
kapa.ai
kapa.ai11mo ago
Let me check the knowledge base for you. One moment! :books: ---------------------- If the error is occurring in the Refine core itself, it might be due to a misconfiguration in the project setup or an issue with the dependencies. Here are a few steps you can try: 1. Reinstall node modules: Delete the node_modules folder and the package-lock.json file (or yarn.lock if you're using Yarn), then run npm install (or yarn if you're using Yarn) to reinstall the dependencies. 2. Check your TypeScript configuration: Make sure your tsconfig.json file is correctly set up. The '@hooks' alias should be defined in the paths field of your tsconfig.json file. 3. Check the version of Refine: Make sure you're using a compatible version of Refine. You can check the version by running npm list @refinedev/core or yarn list @refinedev/core. If none of these steps solve the issue, it might be a bug in Refine. In this case, you can open an issue (https://github.com/refinedev/refine/issues) on the Refine GitHub repository. Be sure to include all the relevant information, such as the exact error message, the version of Refine you're using, and the steps to reproduce the issue. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai11mo ago
<@1205446785254948886> kapa.ai is still learning and improving, please let us know how it did by reacting below
multiple-amethyst
multiple-amethyst11mo ago
Hey @sonya can you show me your code? What are you importing?
flat-fuchsia
flat-fuchsiaOP11mo ago
import {BaseRecord, HttpError, LoginFormTypes, useActiveAuthProvider, useLogin, useTranslate} from "@refinedev/core"; import {AuthPage, ThemedTitleV2} from "@refinedev/mui"; I tried create custom auth-page mui
multiple-amethyst
multiple-amethyst11mo ago
Can you provide a minimal reproducible example? I tried to with your imports, there is no error.
correct-apricot
correct-apricot11mo ago
Hello, I'm sonya and I'm writing from a different account. Thanks for trying to solve my problem. In general, I found that the error was coming from a completely different place. Namely when I exported from deep dependencies. I don’t know why this happened and auto import worked like that... import {CrudOperators} from "@refinedev/core/src/contexts/data/IDataContext"; Hope this helps someone

Did you find this page helpful?