Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

215
Visualizações
VSCode not showing correct import suggestions for a local linked package

VSCode is not offering import suggestions correctly for a package that was linked locally (using npm link).

Normally when I want to use a class from a package, I'd write Foo and press tab to automatically add the import for myModule/Foo.js. But in my current setup, I am not getting import suggestions for myModule at all.

My folder structure looks like this:

project
|-  server (node package)
|   |-  node_modules/
|   |-  src/
|   |-  package.json
|-  myModule (node package)
    |-  src/
    |-  package.json

All packages are of the module type (es6 import/exports).

"type": "module"

The myModule package uses a subpath export to hide the src folder:

"exports": {
  "./*": "./src/*"
}

Then I used npm link in project/myModule, followed by npm link myModule in project/server. I can then use myModule in server/src/index.js as follows:

import Foo from "myModule/Foo.js"
import Four from "myModule/Bar/Four.js"

At this point, Node is happy. Unfortunately, VSCode is not. When using Foo or Bar and using the IntelliSense suggestion to automatically add the import, I get the following result:

  • No import suggestions at all with the setup described above.
  • VSCode adding an import through a relative path (E.g: ../../myModule/src/Foo.js) if I remove the subpath export from myModule.
  • I tried adding a jsconfig.json with a path alias like: "myModule/*": ["./node_modules/myModule/src/*"] or "myModule/*": ["./node_modules/myModule/*"] but unfortunately that didn't make a difference.

What can I do to have working import suggestions again in VSCode?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Placing a jsconfig.json in project/ with "myModule/*": ["./myModule/src/*"] as a path alias has made VSCode happy again.

This may present other challenges further down the line, as I'm now specifying this alias for every package in project/. Other suggestions are still very much welcome, as well as an explanation why jsconfig.json in project/server/ was not working as expected.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda