Your library must have this configuration in angular.json
under architect > options > project
:
"my-library": {
"projectType": "library",
...
"architect": {
"build": {
"builder": "@angular-devkit/build-ng-packagr:build",
"options": {
...
"project": "projects/my-library/ng-package.json"
},
...
And your ng-package.json file must be:
{
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../../dist/my-library",
"lib": {
"entryFile": "src/public-api.ts",
"umdModuleIds": {
}
}
}
Also you must have a public-api.ts
file:
// public-api.ts
/*
* Public API Surface of my-library
*/
export * from './lib/my-library.module';
...
Do you have all those files and configurations?
These are all configurations that should take place automatically when you create a library.
For reference you can watch:
https://angular.io/guide/creating-libraries
UPDATE:
"Currently I am copying my package.json into the dist folder and then running npm pack inside the dist folder."
With a gulp batch you can copy package.json from root to dist:
// /gulpfile.js
var gulp = require('gulp');
gulp.task('default', [], function() {
gulp.src(['../../my-library/package.json']) // pay attenction to your relative path where you run gulp.
.pipe(gulp.dest('my-library/dist'));
});
To run it:
gulp default
In the gulp file directory.
And then try with npm pack
in dist folder.