fair-rose
fair-rose13mo ago

Weird error in refine build

Hello, I have this error and I don't know what to do :
Failed to compile.

TS2307: Cannot find module 'src/interfaces' or its corresponding type declarations.
1 | import { ReactNode, ComponentType } from "react";
2 | import { UseQueryResult } from "@tanstack/react-query";
> 3 | import { ILogData } from "src/interfaces";
| ^^^^^^^^^^^^^^^^
4 |
5 | /**
6 | * Resource route components
Failed to compile.

TS2307: Cannot find module 'src/interfaces' or its corresponding type declarations.
1 | import { ReactNode, ComponentType } from "react";
2 | import { UseQueryResult } from "@tanstack/react-query";
> 3 | import { ILogData } from "src/interfaces";
| ^^^^^^^^^^^^^^^^
4 |
5 | /**
6 | * Resource route components
My tsconfig / tsconfig.node.json
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": ["src", "vite.config.ts"],
"references": [
{
"path": "./tsconfig.node.json"
}
]
}
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": ["src", "vite.config.ts"],
"references": [
{
"path": "./tsconfig.node.json"
}
]
}
{
"compilerOptions": {
"composite": true,
"module": "ESNext",
"moduleResolution": "node"
},
"include": ["vite.config.ts"]
}
{
"compilerOptions": {
"composite": true,
"module": "ESNext",
"moduleResolution": "node"
},
"include": ["vite.config.ts"]
}
19 Replies
kapa.ai
kapa.ai13mo ago
Hi @realdragonma. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
fair-rose
fair-rose13mo ago
My package.json
{
"scripts": {
"dev": "refine dev",
"build": "refine build",
"preview": "refine start",
"refine": "refine"
},
"type": "module",
"dependencies": {
"@ant-design/icons": "^5.1.4",
"@iconify/react": "^4.1.1",
"@refinedev/antd": "^5.28.0",
"@refinedev/cli": "^2.7.2",
"@refinedev/core": "^4.26.4",
"@refinedev/kbar": "^1.1.2",
"@refinedev/react-router-v6": "^4.3.2",
"@refinedev/simple-rest": "^4.5.0",
"antd": "^5.6.4",
"axios": "^1.4.0",
"dayjs": "^1.11.9",
"i18next": "^23.2.8",
"i18next-browser-languagedetector": "^7.1.0",
"i18next-http-backend": "^2.2.1",
"process": "^0.11.10",
"query-string": "^7.1.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-i18next": "^13.0.1",
"react-router-dom": "^6.14.1",
"react-scripts": "^5.0.1",
"socket.io-client": "^4.7.1",
"uuid": "^9.0.0"
},
"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@types/node": "^18.16.19",
"@types/react": "^18.2.14",
"@types/react-dom": "^18.2.6",
"@vitejs/plugin-react": "^4.0.2",
"typescript": "^4.9.5",
"vite": "^4.4.1"
},

}
{
"scripts": {
"dev": "refine dev",
"build": "refine build",
"preview": "refine start",
"refine": "refine"
},
"type": "module",
"dependencies": {
"@ant-design/icons": "^5.1.4",
"@iconify/react": "^4.1.1",
"@refinedev/antd": "^5.28.0",
"@refinedev/cli": "^2.7.2",
"@refinedev/core": "^4.26.4",
"@refinedev/kbar": "^1.1.2",
"@refinedev/react-router-v6": "^4.3.2",
"@refinedev/simple-rest": "^4.5.0",
"antd": "^5.6.4",
"axios": "^1.4.0",
"dayjs": "^1.11.9",
"i18next": "^23.2.8",
"i18next-browser-languagedetector": "^7.1.0",
"i18next-http-backend": "^2.2.1",
"process": "^0.11.10",
"query-string": "^7.1.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-i18next": "^13.0.1",
"react-router-dom": "^6.14.1",
"react-scripts": "^5.0.1",
"socket.io-client": "^4.7.1",
"uuid": "^9.0.0"
},
"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@types/node": "^18.16.19",
"@types/react": "^18.2.14",
"@types/react-dom": "^18.2.6",
"@vitejs/plugin-react": "^4.0.2",
"typescript": "^4.9.5",
"vite": "^4.4.1"
},

}
So basically i can't build
kapa.ai
kapa.ai13mo ago
---------------------- The error message you're seeing is indicating that TypeScript cannot find the module 'src/interfaces'. This could be due to a few reasons: 1. The file or directory 'src/interfaces' does not exist. Make sure that you have a directory named 'interfaces' inside your 'src' directory and it contains the necessary files (like index.d.ts). 2. The path to the 'src/interfaces' is incorrect. If your 'interfaces' directory is not directly under 'src', you might need to adjust the path. 3. Your tsconfig.json file is not properly configured to include the 'src/interfaces' directory. In your tsconfig.json, you have included the 'src' directory, which should theoretically include all subdirectories. However, if for some reason it's not working, you can try to explicitly include 'src/interfaces' in the 'include' array. If you're using path aliases (as described in the Next.js with TypeScript guide (https://refine.dev/blog/next-js-with-typescript)), make sure that they are correctly configured in your tsconfig.json. For example, you might have something like this:
"baseUrl": ".",
"paths": {
"@/interfaces/*": ["src/interfaces/*"]
}
"baseUrl": ".",
"paths": {
"@/interfaces/*": ["src/interfaces/*"]
}
In this case, you would import from '@/interfaces' instead of 'src/interfaces'. Please check these points and adjust your code accordingly. If the problem persists, it might be helpful to see the structure of your 'src/interfaces' directory and the exact import statement that's causing the error. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai13mo ago
<@214840332943097856> kapa.ai is still learning and improving, please let us how it did by reacting below
fair-rose
fair-rose13mo ago
No description
fair-rose
fair-rose13mo ago
@kapa.ai so i deleted tsconfig.node.json and here is my new tsconfig.json:
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"baseUrl": ".",
"paths": {
"@/interfaces/*": ["src/interfaces/*"]
}
},
"include": ["src", "vite.config.ts"],

}
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"baseUrl": ".",
"paths": {
"@/interfaces/*": ["src/interfaces/*"]
}
},
"include": ["src", "vite.config.ts"],

}
And it doesn't work at all, here is the error :
Failed to compile.

TS2307: Cannot find module 'src/interfaces' or its corresponding type declarations.
1 | import { ReactNode, ComponentType } from "react";
2 | import { UseQueryResult } from "@tanstack/react-query";
> 3 | import { ILogData } from "src/interfaces";
| ^^^^^^^^^^^^^^^^
4 |
5 | /**
6 | * Resource route components
Failed to compile.

TS2307: Cannot find module 'src/interfaces' or its corresponding type declarations.
1 | import { ReactNode, ComponentType } from "react";
2 | import { UseQueryResult } from "@tanstack/react-query";
> 3 | import { ILogData } from "src/interfaces";
| ^^^^^^^^^^^^^^^^
4 |
5 | /**
6 | * Resource route components
kapa.ai
kapa.ai13mo ago
Let me check the knowledge base for you. One moment! :books: ---------------------- The error message is still indicating that TypeScript cannot find the module 'src/interfaces'. However, you have now configured a path alias in your tsconfig.json. This means you should adjust your import statement to use the alias instead of the absolute path. Change your import statement from:
import { ILogData } from "src/interfaces";
import { ILogData } from "src/interfaces";
to:
import { ILogData } from "@/interfaces";
import { ILogData } from "@/interfaces";
This should resolve the issue, as long as the ILogData interface is correctly defined and exported in your 'src/interfaces' directory. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai13mo ago
<@214840332943097856> kapa.ai is still learning and improving, please let us how it did by reacting below
fair-rose
fair-rose13mo ago
@kapa.ai I don't want to change file in my node_modules ... You're proposing something a bit forbidden here, how clean do you want it to be to modify a file in my node_modules folder, especially since it's from refine, I'm not going to modify that.
kapa.ai
kapa.ai13mo ago
Let me check the knowledge base for you. One moment! :books: ---------------------- I apologize for any confusion, but I must clarify that I'm not suggesting you modify any files in your node_modules directory. Modifying files in node_modules is indeed not recommended as these changes can be overwritten when you install or update your dependencies. The changes I suggested are meant to be made in your project's source code and configuration files, specifically your import statements and tsconfig.json file. These files are part of your project's source code, not the node_modules directory. If you're seeing an error related to a file in node_modules, it's likely that there's an issue with how your project is configured or how you're using the library, not with the library itself. If you believe there's an issue with refine itself, I would recommend creating an issue in the refine GitHub repository (https://github.com/pankod/refine) so that the maintainers can investigate. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai13mo ago
<@214840332943097856> kapa.ai is still learning and improving, please let us how it did by reacting below
fair-rose
fair-rose13mo ago
@kapa.ai Sorry for the confusion, but if you're asking me to modify a file from the node module, this import is done in node_modules/@refinedev/core/src/interfaces/bindings, so it's a node_modules file.
kapa.ai
kapa.ai13mo ago
Let me check the knowledge base for you. One moment! :books: ---------------------- I see, I misunderstood the context of your question. I apologize for the confusion. If the import statement that's causing the error is in a file within the node_modules/@refinedev/core package, then you should not modify that file. The error might be due to a misconfiguration in your project or an issue with the package itself. Here are a few things you can try: 1. Reinstall your node_modules: Sometimes, issues can be resolved by deleting your node_modules directory and package-lock.json (or yarn.lock) file, and then running npm install (or yarn if you're using Yarn) to reinstall your packages. 2. Check your TypeScript version: Make sure you're using a version of TypeScript that's compatible with the @refinedev/core package. You can check the required TypeScript version in the package's documentation or package.json file. 3. Update @refinedev/core: If you're not using the latest version of @refinedev/core, try updating to the latest version. There might have been a bug in the version you're using that's been fixed in a newer version. If none of these suggestions work, I recommend reaching out to the maintainers of @refinedev/core for help. You can create an issue in the refine GitHub repository (https://github.com/pankod/refine) describing your problem and the steps you've taken to try to resolve it. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai13mo ago
<@214840332943097856> kapa.ai is still learning and improving, please let us how it did by reacting below
fair-rose
fair-rose13mo ago
@kapa.ai doesn't work, same error
kapa.ai
kapa.ai13mo ago
Let me check the knowledge base for you. One moment! :books: ---------------------- I'm sorry to hear that you're still experiencing the issue. As an AI, I'm limited in how much I can help with specific code issues. However, I would strongly recommend reaching out to the maintainers of the @refinedev/core package for further assistance. You can create an issue in the refine GitHub repository (https://github.com/pankod/refine) describing your problem and the steps you've taken to try to resolve it. They should be able to provide more specific guidance based on their knowledge of the package. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai13mo ago
<@214840332943097856> kapa.ai is still learning and improving, please let us how it did by reacting below
fair-rose
fair-rose13mo ago
@kapa.ai Can you ping a manager ?
kapa.ai
kapa.ai13mo ago
Let me check the knowledge base for you. One moment! :books: @realdragonma That's a great question, but unfortunately I am only capable of responding to a maximum of three questions per thread. Don't hesitate to create a new thread for any further questions you have though. I'm here to help!