I just started a Solidjs
project and it seems that when i try to use the auto import
, it doesn't include the ./
which causes import problems in Vite
. Example is "import Dashboard from "routes/Dashboard";"
. As you can see, the ./
is missing and this causes a Failed to resolve import "routes/Dashboard" from "src\App.jsx". Does the file exist?
error
This would be a big hassle if every time i need to manually fix the import in the future. I have tried searching in the internet but its either i am not using the correct terms in searching this solution or no one else has encountered this problem. How do i fix this? Also i am using VScode as my editor.
jsconfig.json
{
"compilerOptions": {
"strict": true,
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"jsx": "preserve",
"jsxImportSource": "solid-js",
"types": ["vite/client"],
"noEmit": true,
"isolatedModules": true,
"checkJs": true,
"baseUrl": "./src",
},
}
settings.json in vscode
{
"dart.flutterSdkPath": "C:\\Flutter\\flutter",
"workbench.iconTheme": "material-icon-theme",
"[javascriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"javascript.updateImportsOnFileMove.enabled": "always",
}
Found the solution. The culprit is "baseUrl": "./src",
in jsconfig.json
. I removed the line and it seems to work normally.