Is it possible for absolute paths to autocomplete in Visual Studio Code (VSCode)?
VS Code does not support using NODE_PATH
for intellisense. To achieve what you want, create a jsconfig.json
file at the root of your project with the contents:
{
"compilerOptions": {
"target": "ES6",
"baseUrl": "./src"
},
"exclude": [
"node_modules",
"**/node_modules/*"
]
}
The important setting is baseUrl
. It tells VS Code to resolve non-relative paths relative to the ./src
folder
After configuring jsconfig
and baseUrl
, you can also set "javascript.preferences.importModuleSpecifier": "non-relative"
in VS Code to specify that VS Code should always try to use paths to use the baseUrl