TS2305 when nested tag is different

  git, javascript, npm, tags, typescript


- another-package
  - commonly-used-types#1 (tag 1)
- commonly-used-types#2 (tag 2)

added code:

import { MyClass } from 'commonly-used-types';

Build failed. Import of commonly-used-types points #1, not #2. There’s no MyClass on #1.

error TS2305: Module ‘"../../../../../../../../../Users/devheedoo/Dev/actual-project/node_modules/another-package/node_modules/commonly-used-types/dist"’ has no exported member ‘MyClass’


We use 2 repositories. One for commonly used types, and one for actual project.

We add and export MyClass interface to type repository, then add git tag #2.

// commomnly-used-types repository
export interface MyClass { ... }

We import MyClass interface to actual project repository.

// actual-project repository
import { MyClass } from 'commonly-used-types';

const myClass = new MyClass();
// ...
  "dependencies": {
    "another-package": "git+ssh://[email protected]/username/another-package"
    "commonly-used-types": "git+ssh://[email protected]/username/commonly-used-types.git#2"

But we got the following error:

error TS2305: Module ‘"../../../../../../../../../../../Users/choco/Dev/actual-project/node_modules/another-package/node_modules/commonly-used-types/dist"’ has no exported member ‘MyClass’

There another package uses older tag(#1) of commonly-used-types.

  "dependencies": {
    "commonly-used-types": "git+ssh://[email protected]/username/commonly-used-types.git#1"


We could fix it using detail path:

// before
import { MyClass } from 'commonly-used-types';

// after
import { MyClass } from './dist/node_modules/commonly-used-types';

But I wonder why the import statement points commonly-used-types in another package’s node_modules?

To use only package name for import, should we sync tag of commonly-used-types in another-package every time the tag updates?

Source: Ask Javascript Questions