Reputation: 17357
I've a directive that I want to publish on npm. I read the doc here and after that here is what I did:
npm init
and npm publish
npm install --save-dev
my published packageHowever it doesn't find the name of the directive when I'm trying to declare it in the module
@NgModule({
declarations: [
AppComponent,
MyDirective //this is not found
],
The js file appears in the module folder though
Upvotes: 1
Views: 2257
Reputation: 17357
Just in case someone in the future might be struggling as I did here are the big steps.
package.json
and add necessary devDependencies.npmignore
:node_modules npm-debug.log *.ts !*.d.ts
I hope I didn't miss anything, in any case the tutorials above in the accepted answer will help
Upvotes: 1
Reputation: 16917
You imported import {...} from 'your-package-name/your-main-js';
it, right?
Here's a nice guide to create npm packages for Angular2.
https://medium.com/@OCombe/how-to-publish-a-library-for-angular-2-on-npm-5f48cdabf435#.coog6uf98
If you want to create a component package, remember to inline your templates/styles ! Otherwise your app will be broken..
Or you could use a script like this https://github.com/ludohenin/gulp-inline-ng2-template to inline those templates/styles..
Maybe this repo as a starting point will help: https://github.com/mxii/ng2-offclick
You can also take a look at these resources:
Upvotes: 2