DEV Community


How to test NPM package locally

Avinash Dalvi
AWS Community Builder | Full Stack Developer | PHP + Angular + Python + AWS | Speaker | Blogger | Leadership I write blog at
・1 min read

I started contributing to Angular and NPM packages. One of main issue i faced is how to debug this NPM package locally before committing.

I tried search around StackOverflow and Medium. Found NPM has one best think is npm link and npm unlink. Using this command you can create symbolic link to local package to global node_modules or inside Angular project node_modules

Here is documentation available for npm link and npm unlink

First tried running command npm link inside NPM package and npm link foldername this foldername is same NPM package folder name. But this didn't work.

Why ?

  • Because package name was using author name in package. It called as scope in node modules. In my case its something like this @username/foldername.

How do link this ?

  • Same as normal command only mention npm link @username/foldername and for Angular project npm link @username/foldername. This name generally from package.json

And what ?

Its works like rocket...🚀🚀🚀🚀

Discussion (0)