How can I test local installation of an NPM package I've published?

445 views Asked by At

I recently published a package to NPM. The package works well on my own computer, where I wrote the code, but upon npm install on a coworkers machine, I start receiving errors.

What is the best way to go about installing and testing my package on my own computer? I could trace through the errors on my coworkers computer, but I assume there is a way I can do this on my own machine.

1

There are 1 answers

0
CherryNerd On BEST ANSWER
  1. You don't have to install it on your own computer first if you want to test it, you could write unit tests instead, since you have to require the package if you do (just like an npm install).
  2. Check the package.json to see if all needed modules are listed under dependencies. (Delete the node_modules folder, run npm install and see what errors are given)
  3. If there is a file called .npmrc, check what files/folders it lists to make sure it's not excluding important files from NPM.
  4. Make sure your module has a module.exports object, to be able to access the objects/functions

If this all didn't help, it might be a more specific problem and a GitHub link would help us more