To be able to use absolute paths in TypeScript we can set the baseUrl property in the tsconfig. json file. With this, we define src as our root directory (for module resolution).
In Visual Studio Code, menu File → Preferences → Settings → User Settings,
"typescript.preferences.importModuleSpecifier": "relative"
It works fine for me. It imports
import { RegistrationComponent } from '../../abc-modules/registration/registration.component';
in place of
import { RegistrationComponent } from 'app/abc-modules/registration/registration.component';
I landed here from Google and had the opposite problem. My Visual Studio Code instance always imported the relative path even though it was from a different Lerna package.
It turns out that I simply forgot to add the package that it was wrongly importing to my consuming package’s package.json
file.
Now, everything works as expected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With