I'm loosely following this tutorial to create my own angular npm package called customlib
so I can manage dependencies across my projects without making them public on npm.
in my app.module.ts
I get a module not found: Can't resolve 'customlib'
error when I do the following:
import { customModule } from 'customlib';
it works fine if I do this though:
import { customModule } from '../../node_modules/customModule/dist-lib/index';
Is there something I'm missing? it's worth noting that I move all files I want to include in my package to the dist-lib
directory.
My library's package.json
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"
}
I'm adding the dependency in the consumer project's package.json
as so:
"customlib" : "path/to/repo"
And I've also added the following to the consumer project's tsconfig.json
:
"include": [
"src/**/*.ts",
"node_modules/customlib/dist-lib/index.ts"
]
Try on consumer package.json dependencies:
"customlib" : "file:path/to/repo"
And not forget "npm install".
I found a resource that was published by angular team that describes about creating a angular package . And in here you can fin some examples as well as some packaging libraries.
Please go through this document. Hope this helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.