absolute imports works fine in VScode but not compiled #16114
-
that is my configs in tsconfig.json file "baseUrl": ".",
"paths": {
"@src/*": ["./src/*"],
"@hooks/*": ["./src/hooks/*"],
"@components/*": ["./src/components/*"],
"@root/*": ["./*"]
} these are recognized by vscode and it auto completes the directories for me but I got this error in the browser and terminal
however, I'm using the latest next package 9.5 |
Beta Was this translation helpful? Give feedback.
Answered by
jamesmosier
Aug 12, 2020
Replies: 1 comment 2 replies
-
On {
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/components/*": ["./src/components/*"]
}
}
}
import Test from '@/components/test';
export default function Home() {
return (
<div>
<Test />
</div>
);
}
export default function Test() {
return <p>test</p>
} Could you import your AppHeader via |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
mhesham32
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On
9.5.2
with mytsconfig.json
and pages setup like this, it works:src/pages/index.js
src/components/test.js
Could you import your AppHeader via
import AppHeader from '@/components/AppHeader';
instead ofimport AppHeader from '@/src/components/AppHeader';
?