This week we have to implement versioned relase and publish it to npm.
Clean Up
Right now I run the application via node index.js
which is inconvenient when you are using it like a npm package running under node. So, the first step was to ensure it can run with explainer --args
. So I had to make some adjustments.
Research
Next step was to do do some research on how I can upload my project on npm. First resource I came across was how I can unscoped public packages. Looking through the steps everything seemed to be done. Then I noticed the section about .npmignore
to exclude files that I don't want to publish to npm. And finally I'm supposed to run npm publish
.
So I did some research on .npmignore
. And I found this part in the docs on what files I should exclude. So I made my .npmignore
. I also took the opportunity to update my README.md to reflect how I'm supposed to install the package and updated the usage of my tool as well. Next I ran
npm publish
But I got an error saying I should run
npm adduser
Normally that would open the browser to login from the browser. Since I'm using WSL I had to find a way to login via ternimal. So, I found this Stackoverflow thread. In short, to login via terminal run
npm login --auth-type legacy
After I ran
npm publish
And my application was published.
Testing
For my testing I choose someone that is not taking the course. We hopped on a call and I gave him the npm link. First issue he faced was two different installation script. One generated by npm and what I wrote npm i explainer.js
vs npm install -g explainer
. Next, when running inside a project it works fine. But the issue was it reads the package.json
from the current directory. So it was reading package.json
from his project. Cause it was showing version of his project instead the one in my package.json
. And if opened just from a terminal it'd crash. So I went back to my code and realized the issue of reading package.json. So I had to make some adjustments and it was extra difficult since I cannot use __dir
since I'm using ESM. So I had to look up how to make it work under ESM. After the fix I updated the README.md again and pushed and released released another version. This time it went perfect and there was no issue.
Release 0.1.0 π
And finally (drumrolls please), Explainer.js is out for everyone. Checkout it out @ https://www.npmjs.com/package/explainer.js
Top comments (0)