'VSCode - Import suggestions for JavaScript don't work
Any ideas why Import intellisense/suggestions wouldn't work in a JS project? Here's the jsconfig.json file:
{
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"target": "esnext",
"baseUrl": "./src/",
"paths": {
"@src/*": ["*"],
"@core/*": ["core/*"]
},
"esModuleInterop": false
},
"exclude": ["node_modules"]
}
It is a node project, that has path aliasing achieved with the "module-alias" NPM package. Here are the aliases in package.json:
"_moduleAliases": {
"@src": "./src",
"@core": "./src/core"
}
Code works fine during runtime, but VSCode doesn't offer any import suggestions. If I have an undefined function in script A.js, it doesn't offer to import it from script A.js.
I got it to help with imports by setting checkJs
to true
in jsconfig.json, but even then it auto-generated the imports using the new import/export syntax, even though I need them imported in the CommonJS format.
Here's another issue that VSCode has that could be related. It shows an error in jsconfig.json that seems completely unrelated to it. The error itself is pretty strange as well.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|