0

I would like create a npm package for a project. I used angular-cli to create my components I would like package.

My tsconfig.json

{
   "compilerOptions": {
      "declaration": true,
      "emitDecoratorMetadata": true,
      "experimentalDecorators": true,
      "lib": ["es6", "dom"],
      "mapRoot": "./",
      "module": "es6",
      "moduleResolution": "node",
      "outDir": "../dist/out-tsc",
      "sourceMap": true,
      "target": "es5",
      "typeRoots": [
        "../node_modules/@types"
      ]
   } 
}

I can generate *.d.ts with ng build

And then, with npm link I can test my package into other project, but my module which contains my components is not found.. :/

Have you some ideas ? :)

Pierre-Luc BLOT
  • 419
  • 6
  • 20
  • Your question is not really clear as to what your issue is - are you saying that you build out your app and it doesn't work? Because that could be related to this: http://stackoverflow.com/questions/37558656/angular-clis-ng-build-doesnt-produce-a-working-project – Zze Jan 25 '17 at 21:54
  • I can not generate my project in order to use it in another project as a dependency with npm – Pierre-Luc BLOT Jan 25 '17 at 21:58
  • 1
    Currently you're not able to do it via CLI. Follow this thread, you can find a lot of interesting stuff here: https://github.com/angular/angular-cli/issues/1692#issuecomment-273989471 – DDRamone Jan 25 '17 at 22:13
  • There is a post and sample code [here](https://www.usefuldev.com/blog/post/publishing-a-library-from-an-angular-cli-project) showing how to isolate a module in an Angular-cli project and publish it as an npm package which might be helpful. – JayChase Aug 20 '17 at 05:37

1 Answers1

4

Hi I think this documentation will help you. I have successfully created npm package using yoman from my angular2 component.

Soojoo
  • 2,402
  • 1
  • 30
  • 56