Rob
Rob

Reputation: 11788

How do I create an npm package from an existing one?

I'm relatively new to node and the npm package system. For my redux/react web application, I currently use the photoswipe package in combination with react-photoswipe. Now I wanted to add some extra functionality to the photoswipe package, so I went into the photoswipe folder in the npm-modules folder, made the required changes and ran npm build in there.

This works, but the changes will of course be lost as soon as for whatever reason the node_modules-folder gets deleted and recreated, or if I upgrade the photoswipe package.

What is the correct workflow in this case? Can I somehow clone the existing package, change it, then store it in something like a local repository that npm recognizes? Thanks alot for clarification!

Upvotes: 0

Views: 88

Answers (1)

Victor Parmar
Victor Parmar

Reputation: 5779

The answer depends on the license of the photoswipe package. If it is open source then I would highly recommend that you open a pull request with your changes so that everyone benefits from your feature :)

That being said, you can always clone the package, make your changes and reference the photoswipe package from your github repo. For e.g.: npm install github:alex-cory/fasthacks

Upvotes: 1

Related Questions