It's time for another Angular Knowledge Pill!
It takes just a couple of seconds to learn something new 🔥
Like taking your morning vitamins 😃
If you are working on a library that you want to import to your application you don't have to publish it to any npm repository! You can link it locally. Imagine you develop an Angular library or maybe you have your CSS theme in a separate npm package that you want to import to your application locally. You can use npm link command like below. 😎
npm link creates a symbolic link (symlink) from your
<global node_modules>directory to the local library’s directory.
npm link <library-name> creates a symbolic link from project's local node modules directory
To locate your
<global node_modules> directory, type
npm root -g in the command line.
Now, you can import your library directly in your application like below. But, there is a catch! 😱
The catch is that you need one more change in your
angular.json file! You need to add a property
preserveSymlinks as presented below. And that's it! You can run your application with the local dependency! 🔥
If you would like to receive this kind of knowledge pills directly into your mailbox, subscribe at angular-academy.com/blog/. I will be sending them regularly! Remember, it just takes 10 seconds to learn something new! 😃
Throughout the last year, I have worked part-time as a working student and also studied at the university. I was not the first and not the last one who has combined that during their studies, but the problem for me was, that at the end of the day I have felt absolutely exhausted mentally and physically. That caused problems with my health and motivation to continue working on my goals or anything. (yeah, “goals,” I wish I had something more specific at that time).