0

I used the Yeoman generator (https://github.com/jvandemo/generator-angular2-library) to create an Angular library called my-lib. My angular app is consuming the created library and everything works fine.

The only issue I had is that in the development mode, I have to make frequent changes on my library and execute some commands to rebuild and publish the library to NPM :

npm run build
npm publish dist

Once I published the library to the NPM registry, I reimport it in my Angular app using the npm install command.

Is there a better way or a shorter path (in the development mode) for detecting changes on the library and reflectiong them to my consuming app ?

ps: The creation of a symlink in the global node_modules directory to the dist directory of the library:

$ cd dist
$ npm link 

And linking the global library directory to node_modules of the app directory:

$ npm link my-lib

Does not solve the problem..

baj9032
  • 2,414
  • 3
  • 22
  • 40
m.bouali
  • 484
  • 1
  • 4
  • 15
  • How does symlink not solve the problem? This is how I typically develop with multiple packages, works no problem for me. – Malcor May 15 '18 at 11:25
  • For every change in the lib, you have to run : npm run build, npm link (from the dist folder) and the then npm link lib (from the consuming app).. Is that true ? – m.bouali May 15 '18 at 11:27
  • Nope, in the project you want to access the dependency, run `npm link "{Directory of dep}"` and you should be good to code. Live reload probably won't work, but you can just refresh the page. – Malcor May 15 '18 at 11:30
  • Checkout this answer on [Stackoverflow](https://stackoverflow.com/a/17371987/1818637) – Malcor May 15 '18 at 11:33

0 Answers0