Currently, I am loosely following a tutorial on creating an angular npm package named customlib
. This package is intended for managing dependencies across my projects without the need to make them public on npm. The tutorial can be found here.
However, I encounter a 'module not found: Can't resolve 'customlib'' error in my app.module.ts
file when trying to import it using:
import { customModule } from 'customlib';
In order to successfully import, I have to use the following path:
import { customModule } from '../../node_modules/customModule/dist-lib/index';
I'm wondering if there's something missing in my setup or configuration. It's important to note that all the files I want to include in my package are moved to the dist-lib
directory.
The package.json
of my library looks like this:
{
"name" : "customlib",
"version" : "0.1.0",
"private" : true,
"dependencies" : [
...
],
"files" : [ "dist-lib/" ],
"repository" : {
"type" : "git",
"url : "path/to/repo"
},
"types": "dist-lib/index.d.ts"
}
To add the dependency in the consumer project's package.json
, I use the following format:
"customlib" : "path/to/repo"
Additionally, I've made sure to include the necessary paths in the consumer project's tsconfig.json
:
"include": [
"src/**/*.ts",
"node_modules/customlib/dist-lib/index.ts"
]