I'm trying to include a local library, so i follow theese 2 tutorials: how to create library, how to consume local library. So, i have a nice sample library (it has package.json, index.ts, etc), i try to include it in my main project (npm link
works fine, i can see a symlink to my lib), but i cant refer it from my main project.
import { HelloWorld } from "my-test-lib"; // "Cant find module"
Also, i tried to install it via npm install ../libs/my-test-lib
, but results are the same: "Cant find module". Any suggestions on how to include it to my project?
PS: i'd prefer something like npm install
, so i'd be able to commit this change to the repository (as opposing to npm link
).
EDIT (why its not a duplicate): in how to specify local modules as npm package dependencies its not clear which way to go: both "bar":"file:../foo/bar"
and npm link
are not working for me for the reason mentioned above.
EDIT2: Okay, i've tried "preinstall": "npm ln my-test-lib ../libs/my-test-lib"
in the package.json. And then import { HelloWorld } from "my-test-lib";
. Still the same error "Cannot find module". Can it be something wrong with the package itself?
EDIT3: So yes, the main point of this question is to figure out why
// package.json
"dependencies": {
"my-test-lib": "file:../lib/my-test-lib"
}
// ts file
import { HelloWorld } from "my-test-lib";
is not working. Wondering, how can i debug that.
Or