I have a library which is written in typescript and is normally installed via npm. Currently I'm developing some app that requires it and I often need to make some changes in it as well. The ideal situation for me would be if I just could edit my library directly and see the changes in my app. I've tried with npm link but without success. How can use it with typescript?
-
Any chance you've found a way to do this?s.smsmsm– s.smsmsm2024-09-19 11:09:06 +00:00Commented Sep 19, 2024 at 11:09
Add a comment
|
1 Answer
You can npm link to your library but it needs to be compiled first.
Lets say you have project P that depends on library L, which are all local to you:
./repos
./P
project.json
./L
./src
./dist
project.json
The file /repos/L/project.json should have a entry main pointing to the main file of the library in dist. You have to compile the library (using tsc) to generate dist.
Then you do
$ cd repos/L
$ tsc # or maybe npm run build
$ cd ../P
$ npm link ../L
And that's it.
1 Comment
Karol Samborski
OK, but this way I would need to compile it every time I make a change in the library. I would like to work on .ts files directly. That's why I wrote that I couldn't get it working with
npm link