英文:
MUI auto import suggestions not working in VS Code, Next.js 13 project
问题
我正在开发一个基于 Next.js 13
的项目,已安装了 MUI
,但是 VS Code 不提供从 @mui/material
库进行自动导入。如截图所示。
在这个文件夹中,从其他库进行的自动导入正常工作。在不基于 Next.js 13
的其他项目中,也可以正常从 MUI
进行自动导入。
请告诉我如何解决这个问题?
以下是我的 tsconfig.json 文件,如果有用的话:
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/": ["./*"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}
感谢关注!
英文:
I'm working on a Next.js 13
project with MUI
installed and VS Code doesn't offer auto imports from the @mui/material
library. This is shown in the screenshot.
Auto imports from other libraries work in this folder. In other projects that are not based on Next js 13
, auto imports from MUI
also work.
Please tell me how can I fix this?
Here is my tsconfig.json if it may help:
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": ["./*"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}
Thanks for attention!
答案1
得分: 1
"It's looking normal. But sometimes need again run VSCode typescript engine when after add new packages.
shift+cmd+p
- 选择 Typescript Reload
Note: 请确保你在 VSCode 中处于正确的文件夹路径。如果你在 VSCode 中启动了错误的项目路径,你将无法看到自动导入的项目包。
也许这个问题不仅与 MUI 有关,也许 这个文档 能帮助你。
英文:
It's looking normal. But sometimes need again run VSCode typescript engine when after add new packages.
shift+cmd+p
- Select Typescript Reload
Note : You have to sure you are at correct folder path on VSCode. If you started wrong project path on VSCode you can't see your project packages with auto imports.
Also this problem isn't relational with only MUI, maybe this document could help you.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论