Hi There,
Today I will talk about my first experience publishing a package to npm. Which means that now you can install it on your machine and use it!
My project is here in case you want to check it.
It is a Static Site Generator; it will take txt or md files as input and transform it in HTML!
Why NPM?
Because I used JavaScript to build my SSG. It runs on Node so npm was the best choice for my case.
Besides, I have been using npm for some years now and I really wanted to try publishing something there.
Preparing my SSG for publishing
Structuring your project is important before publishing it.
Keeping it organized and logical, update your scripts and tests, make sure it has no errors before deploying it to npm.
Because we have been working on it for the past couple months, it was almost ready to be published.
In any case I made tests on different machines to make sure it was working as intended
The Process of Publishing my SSG
To be honest, this step was quite easy and simple.
I followed the steps on npm docs on how to publish and to be honest it consisted in typing only one command in the console.
obs.: The only problem I had was the fact that I had to create an account in NPM and validate it in order to publish my package.
Patching!
After the project was published, I realized there was changes to be made, to apply this changes it was again quite simple.
I had to set a new version to my project and then publish it again
Its There, Go take a Look!
Click here to see my package page on npm!
To install it you need to type:
npm i gmot-ssg
And to run it simple type:
npx gmot-ssg -i yourFileHere.txt
Testing with my Partner
This time my partner was Mizuho.
Her SSG is here.
Her package was well built, and we did not encounter many problems.
We encountered a yargs warning, saying that the ‘version’ word was a reserved word which she quickly solved.
Here is a image of it running fine:
When testing my SSG, Mizuho didn’t find many problems either, the program ran fine and work as intended. No errors, no warnings.
The only curious part was that her npm installs does not create a node_modules
folder on the current directory, at least not for my case.
It send the installed packages to a root directory somewhere in her file systems, something that we could not figure out why at that moment, I bet it was some npm configuration, I believe a reinstall maybe will solve it.
When I tested it in different machines, the node_modules
directory was there, so it was a little intriguing.
Thank you!
Thank you for reading this (David, I believe you are the only one :D), OSD Labs were fun and added a lot to me programming knowledges.
There was a lot of work, I wish I had more time to dedicate my self more but with other 4 courses my time was really reduced.
If you read it until this line, send an emoji on the comments!
Top comments (0)