'Import from node_modules without ../

When I auto import a file from node modules I want it to be like

import ComponentX from "@package/folder"

Instead I get something like

import ComponentX from "../../../node_modules/@package/folder/index"

My jsconfig.json looks like this

{
  "compileroptions": {
    "module": "es6",
    "target": "es6",
    "baseurl": "src"
  },
  "include": ["src"],
  "exclude": ["node_modules"]
}

I use emacs with lsp and ts-server.



Solution 1:[1]

i hope this is gonna give you some insight,

"baseurl" : "src" mean the base path starting point is in the dir /scr,

so try change the base path to the root of your app,

change your baseurl to -> "baseurl" : "."

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Moch Fathurrozi