I'm using WebStorm 2021.2.4, and when I create a Vue.js 3 app I have this error:
It looks like the IDE cannot identify @
as the root directory src
. How can I solve this?
I'm using WebStorm 2021.2.4, and when I create a Vue.js 3 app I have this error:
It looks like the IDE cannot identify @
as the root directory src
. How can I solve this?
To fix "Cannot resolve directory '@'" in PHPStorm 11 for Vue 3.2, Vite 2.9, Laravel 9 & TS
Please check if in root folder of your project a tsconfig.json
file exists. If not, create it and add the following code:
{
"compilerOptions": {
"baseUrl": "./resources",
"paths": {
"@/*": ["js/*"]
}
},
"include": [
"env.d.ts",
"resources/js/**/*",
],
}
If you don't use typescript, just create jsconfig.json
version.
Vite, as well as vite aliases, is not yet supported. Please feel free to vote for WEB-53634 and linked tickets. Actually we can hardly afford supporting all possible ways to define path mappings coming from different bundlers, frameworks and plugins. In the future we'd likely provide some unified way to deal with them in the IDE. For now, I can only suggest creating a dummy config.js
file with all aliases specified explicitly like
module.exports = {
resolve: {
alias: {
'@': path.resolve(__dirname, "src/"] ,
...
},
},
};
and then set the webpack configuration to Manual in Settings | Languages & Frameworks | JavaScript | Webpack and specify a full path to this dummy config there