Webstorm does not see @ alias
I made all recommended method.
1. I set my path to webpack config settings -> Webpack
2. I mark directory as Root.
3. I excluded other folders, includes node_modules.
However, webstorm doesn't see my alias. Help me, please. Linux mint 19
Please sign in to leave a comment.
Please elaborate on your issue. What do you mean saying that aliases aren't recognized? What does your code look like? Please attach screenshots.
Note: there is normally no need to mark any folders in any way to get it working
I have some aliases in my webpack config
But then I try use this in my code
And I can't use CTRL + B for going to my function. Webstorm doesn't see alisases
This should work. What language is it - javascript or typescript? Can you see any messages about webpackconfig resolving in the event log? Please recreate the issue and provide your idea.log file (https://intellij-support.jetbrains.com/hc/en-us/articles/207241085-Locating-IDE-log-files)/ Note: please don't paste it here, upload it to some file server and share a link
I have the same issue, for js
fixed it, but pointing to config
Nope, doesn't work anymore
I'm seeing this same problem. Preferences point to the webpack file, and I have
But it doesn't see the @shared in imports. "Module is not installed," even while files build properly.
Jeremy make sure you don't have any trailing slash '@alias/foo/'
I've the same problem with Vue.js
I'm using the Chris Fritz boilerplate : https://github.com/chrisvfritz/vue-enterprise-boilerplate/
The problem is with the alias on the style Cannot resolve file '@design' :
Try prefixing path with
~
:This doesn't work for me either. It works for my ts/tsx files with tsconfig.json though.
Also I can't include the beginning "@" somehow.
Elena Pogorelova Hi! any updates about that problem? WebStorm doesn't see the @aliases in imports
@Andrewtkachenko99 please provide the detailed problem description
Elena Pogorelova
Next.js project
tsconfig.json
it works, but Webstorm doesn't see '@/components/Button' this path, stresses and shows "Module is not installed". Also i can't go to Button component
Path mappings defined in tsconfig.json only work in TypeScript, they are not taken into account when resolving paths in .js files. You should use webpack aliases there, or try defining your mappings in jsconfig.json instead (@since 2020.1)
you are right. Thanks for help
P.S its a little bit uncomfortable if you have js project in next.js and want to move step by step in typescript. In that case you have tsconfig.json with allowJs property instead jsconfig and aliases doesn't work in webstorm(
Hello ! Any updates on this issue? I'm facing the same problem and its very annoying.
The path to our webpack dev config is set manually.
Here's my Webpack config :
Sorry, what issue? There are no known issues with webpack aliases recognition; it must be smth specific to your setup
NO, I am having the exact problem!
This is not the first time I hear Elena dismiss something with a comment saying "it must be something specific to your setup"...
As I wrote above, there are no known issues with aliases recognition, so your request for status update makes no sense.
Please create a support ticket , providing your idea.log (Help > Show Log in ...) and a problem description (what files your have issues with, what do your imports look like, etc.). The behavior can be different depending on a language/framework being used, etc.
it doesn't work again
Running into a similar issue with a Next.js project. See PR https://github.com/UnlyEd/next-right-now/pull/265
Adding module path aliasing works well with TypeScript (Jest, Next.js, Storybook) even though it requires to configure the paths aliases in 3 different places (a pain, unrelated to WebStorm).
But, for .js files, it doesn't work the same way. (the config being in a "tsconfig.json" file, it doesn't apply to JS)
One solution that seems to work is to create a "jsconfig.json" too, and that's the one WebStorm will use when resolving paths aliases for .js files.
```js
```
```
```
Doing this fixed the `cypress/support/commands.js` file which was doing this:
Without the jsconfig.json, the above was not working. (WebStorm couldn't resolve the path aliases because it knew them for .ts files but not for .js files)
---
Although, I have a similar setup in ".storybook" and the same trick doesn't work there (it builds fine, but WebStorm fails to resolve the module aliases) => It was a WebStorm "syncing/caching" issue, by restarting WebStorm, it got fixed.
Edit: See commit https://github.com/UnlyEd/next-right-now/commit/5df42876b763f2df8fc4892328dc64d916469afd for an example of WebStorm path mapping resolution
Thank you for your insight Ambroise Dhenain!
This fixed my issue with Webpack Alias resolving.
Thank you, I'm glad it helped!
I also wrote an article to explain a bit more the overall configuration and caveats.
https://dev.to/vadorequest/migrating-next-js-jest-storybook-cypress-to-use-module-path-aliases-instead-of-relative-paths-d9a
Just created new vue project, it's ok?
Why does this work in vscode without any configuration?
What IDE version do you use? Did you agree to run webpack when prompted?
I'm also having issues in some of my projects. I believe it's related to the config itself.
When I remove the `devServer` property, it is analyzed fine. The event log shows
Can't analyze webpack.config.js: coding assistance will ignore module resolution rules in this file.
Possible reasons: this file is not a valid webpack configuration file or its format is not currently supported by the IDE.
It sounds like `devServer` isn't supported somehow?
`devServer` is definitely supported. Most probably, the process.env.APP_URL and process.env.APP_PORT can't be resolved during evaluation, causing the issue
I also suspected that the `process.env` properties were the problem, but the following configuration also fails:
Only when I completely remove the `devServer` property does it recognize aliases. My workaround is to start the dev server, then comment that portion out. The dev server still works and I get IDE support for aliases.
For the sake of being thorough, I replaced all my `process.env` parts with their static values. It seems to work after that. Not sure why an empty object would fail.
When I include `require('dotenv').config()` the IDE recognizes the environment afterwards... Thanks Elena Pogorelova for the direction