Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
bromzh opened this issue Apr 21, 2021 · 3 comments
Open

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

bromzh opened this issue Apr 21, 2021 · 3 comments
Assignees

Comments

@bromzh
Copy link

bromzh commented Apr 21, 2021

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

@monarchwadia
Copy link

monarchwadia commented Jul 10, 2021

@bromzh do you have a workaround here? I've tried downgrading tsyringe to 4.4.0, 4.0.0 and 3.4.0, but to no avail.

I just ran across this issue myself. I'm using yarn workspaces, svelte and tsdx in a monorepo. Not sure why this is happening.

I've made my repo public so you folks can triage.
https://github.com/monarchwadia/bootcamp-tycoon

Repro steps:

  1. git checkout f738e6f85cb0842341e4043bd0f162860574430f to go to the broken hash
  2. yarn
  3. cd packages/core && test It should pass all tests
  4. cd packages/web && yarn dev And then visit localhost:3000

Expected behaviour: It should resolve all dependencies
Actual behaviour: Getting TypeInfo not known for...

@monarchwadia
Copy link

monarchwadia commented Jul 10, 2021

Linked repo seems to be working in Inversify. Leaving it here in case you guys could make use of it, you can see it working in commit 0b0e2afc162e42ccbccad053f2a40de340f3f4f1 on my repo.

florian-g2 added a commit to florian-g2/tsyringe that referenced this issue Jun 25, 2022
@florian-g2
Copy link

See: #204 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants