Tips and tricks

How to test package in local development with npm

npm link method

on your angular project library, run npm run build projectname

then in Terminal, navigate on dist/projectname and run npm link

this should create a global symlink in the global npm packages folder, you can find it if you run %APPDATA% and go to npm/node_modules, then if you open it with terminal and run ls

notice that l that marks a symlink

if you

npm link libraryname

in your folder, then you should have the same symlink mark

npm pack method

This is an alternative to npm link. npm link but seems undeterministic to me sometimes

First go to your project folder where you have the package.json and run this command

npm run build

find the dist folder and run

npm pack

Now, right click this .tz file and copy the absolute path.

Next go to your package.json and replace your package link with

"yourpackage": "file:path_to_file.tz"

Check if your plugin is linked

npm ls -g --depth=0 | grep plugin-name-from-package-json
you can undo

if you want to uninstall you can do

npm unlink -g plugin-name-from-package-json

you can also clean your library

npm unlink plugin-name-from-package-json
rm -rf node_modules/plugin-name-from-package-json

yalc method

Install yalc

npm i -g yalc

build library

ng build library --watch

go to library and publish it

cd ./dist/lib
rm -rf /folder-project/.angular/cache
yalc publish --push

you can also push new versions

cd ./dist/lib
rm -rf /folder-project/.angular/cache
yalc push

add it in your project

cd ./proj
ng cache clean
yalc add lib-name

clean yalc

go to your project

yalc remove plugin-name-from-package-json
rm -rf .yalc

then reinstall deps

npm i

Leave a comment

Your email address will not be published

{"type":"main_options","images_arr":"'#ffffff'","enable_ajax":"off","soundcloud_apikey":"","bg_isparallax":"off","bg_slideshow_time":"0","bg_transition":"none","site_url":"https:\/\/digitalzoomstudio.net","theme_url":"https:\/\/digitalzoomstudio.net\/wp-content\/themes\/qucreative\/","blur_ammount":"26","width_column":"50","width_section_bg":"","width_gap":"30","border_width":"0","border_color":"#ffffff","translate_cancel_comment":"Cancel reply","translate_leave_a_comment":"Leave a comment","translate_leave_a_comment_to":"Leave a comment to","is_customize_preview":"off","width_blur_margin":"30","gallery_w_thumbs_autoplay_videos":"off","content_enviroment_opacity":"30","menu_enviroment_opacity":"70","base_url":"https:\/\/digitalzoomstudio.net"}
{"type":"darkfull"}