最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - Visual Studio Code peekgo to definition not working when imports are specified with project name - Stack Overflow

matteradmin4PV0评论

I am working with javascript. Usual cases the imports would look like:

import reducerUtils from '../../utils/reducerUtils'

And the peek definition or go to definition on reducerUtils works as expected.

Things goes different when I change the import to:

import reducerUtils from 'projectname/src/utils/reducerUtils'

The path is definitely valid and the app works too but in the editor the peek definition or go to definition does not work anymore

I understand this could be a standard issue looking from the editors perspective but I was just looking for any solution here to make it work. It might involve into some configuration changes somewhere but my search had no luck. Help Would be appreciated.

I am working with javascript. Usual cases the imports would look like:

import reducerUtils from '../../utils/reducerUtils'

And the peek definition or go to definition on reducerUtils works as expected.

Things goes different when I change the import to:

import reducerUtils from 'projectname/src/utils/reducerUtils'

The path is definitely valid and the app works too but in the editor the peek definition or go to definition does not work anymore

I understand this could be a standard issue looking from the editors perspective but I was just looking for any solution here to make it work. It might involve into some configuration changes somewhere but my search had no luck. Help Would be appreciated.

Share Improve this question edited Dec 26, 2018 at 19:21 Gama11 34.3k9 gold badges90 silver badges106 bronze badges asked Oct 26, 2018 at 9:17 ShocKwav3_ShocKwav3_ 1,7606 gold badges24 silver badges44 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 4

Adding a jsconfig.json file at the root(or wherever appropriate depending on the project). Specify the paths under pilerOptions. eg,

{
  "pilerOptions": {
    "baseUrl": "./",
    "paths": {
      "projectname/*": ["./*"], //it's root in my case
    }
  },
  "exclude": ["node_modules"]
} 

Bit more closer look: https://medium./@justintulk/solve-module-import-aliasing-for-webpack-jest-and-vscode-74007ce4adc9

Official Doc: https://code.visualstudio./docs/languages/jsconfig

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far