Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

213
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!