microsoft / microsoft/tsyringe

TypeInfo not known for "" when use symlinks (i.e. with npm link)

Open
#161 3 comments 2 reactions 1 assignee View on GitHub

@Xapphire13 is already working on this.

Since Apr 21, 2021.

awaiting triage
Dominant language
TypeScript
Stars
6k
Forks
184
Avg merge
3m
Merged PRs (30d)
1

Description

Describe the bug

When I use injectable services (via @injectable decorator) in lib and try to link that lib to my app, I got an error.
But when I use same lib directly in app (via npm install, or just by copying builded lib in app's node_modules for example), error not appears.

To Reproduce

I made a repo with lib and app that uses lib.
NOTE! Please use bash or zsh while reproducing. I not so good in using windows cmd or powershell, so some commands wouldn't works in windows as planned.

Prepearing

git clone https://github.com/bromzh/tsyringe-npm-link-issue.git
  1. Install lib dependencies and build library
cd library
npm i
npm run build
  1. Link library
npm link
  1. Install app dependencies and link library to app
cd ../simple-app
npm i
npm link @my/library

A symlink "@my/library" must appears in app's node_modules after this steps.

Building and running app
Then we'll trying to build our app:

npm run build

Build must be successful if you did all right. After build, we'll trying to run our app:

npm run start

And we got error with these reason:

TypeInfo not known for "ApiService"

BUT! If we publish our lib to repo and install it in app or just copy builded lib to app, all things will be fine.

Use library without symlinks

Copy library directly in app

# work in simple_app directory
rm -rf node_modules/@my
mkdir node_modules/@my
mkdir node_modules/@my/library
cp ../library/package.json node_modules/@my/library
cp -r ../library/build node_modules/@my/library

And then repeat build and run:

npm run build
npm run start

Now all works fine!

Expected behavior

An error TypeInfo not known for ... shouldn't appears when I use npm link.
Both methods - npm link lib and npm install lib - must works well.

Version: ^4.5.0

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.