1

I'm using this paths feature in tsconfig.json to map to local projects:

    "paths": {
      "@MyOrg/MyPackage": ["../MyPackage/src"],
    },

This works great because in my code I can

import { Models } from '@MyOrg/MyPackage'

So now I can work on @MyOrg/MyPackage locally on my machine and I don't need to change my code.

In some cases I want to build with these paths in effect and in other cases I want to build from the NPM package found in node_modules.

Is seems like I should just be able to have two tsconfig files - one which doesn't have the references in it.

What I am finding is that if I use the config file which contains the path, but the path isn't found for whatever reason, the compiler falls back to the one in the node_module folder.

I'm looking for a way to stop this behaviour - if it doesn't find the module at paths reference in my tsconfig, I want it to fail or give an error.

Code Of Light
  • 413
  • 1
  • 2
  • 7
  • Have you looked into switching between a local dependency vs a remote dependency using `npm link`? https://stackoverflow.com/questions/36043423/how-can-i-switch-between-a-linked-npm-dependency-in-development-and-an-install – Terry Jan 12 '22 at 22:26
  • I'm familiar with npm link thanks. I really don't like using it though which is why I'd rather map it manually in my tsconfig - it also means I can full from my repo and know the reference is setup. I've had a lot of frustration with npm link in the past so trying to avoid it if possible. – Code Of Light Jan 12 '22 at 22:37

0 Answers0