I recently published a npm module of mine called wordify on the IPFS network.
First things first, follow the getting started guide. Then run the daemon with ipfs daemon
.
For ease, we will install stay-cli globally:
npm install -g stay-cli
In your repo folder, run stay init
. This will update your scripts section of the package.json with a prepublish script and also create a .publish-dep.sh
file. Update the prepublish script to run your tests before publishing:
"scripts": {
"test": "mocha -R spec ./test/index.js",
"prepublish": "npm test && ./publish-dep.sh"
},
Push to git, bump the npm version with npm version patch
and then npm publish
.
You will see something like this:
## Publishing dependency
Published as QmbNJyd2gEXxeyA94N6ovaeyFsQJ145WheR52YycKoBmKv
To install your module from ipfs, go to (or create) a new app (module, npm init
).
Run stay add hsl-to-hex@...
with the hash of your module:
stay add hsl-to-hex@QmQgM78xDoZeKkqwkahQc8bjSo8zH5XPya4USUa1t297bH
This creates an esDependencies
attribute in your package.json
:
"esDependencies": {
"wordify": "QmbNJyd2gEXxeyA94N6ovaeyFsQJ145WheR52YycKoBmKv"
}
Voila.