How to create your npm card
Lately, our company started growing so I had to start interviewing frontend engineers, UI/UX designers and other developers who focus on the UI aspect of web development
At first, my expectation was that the process wouldnโt involve anything else but talking to a person. I was caught off guard about the fact that a lot these amazing developers shared with me their portfolios, websites or even demos. It was surprising and inspiring to see some of the creative ways people standout.
Because of the simplicity and coolness, one caught my eye as something I could do for myself in less than 15 minutes.
So I did it, you can test it out in your terminal and of course, Iโll show you how to do it. See below ๐
+++
How to runโ
This assumes you have
node
andnpm
installed in your system
- Open your
Terminal
- Type
npx oschvr
and hit enter
npx oschvr
The command will output a nicely formatted ASCII card with my contact information in your terminal. -Nice ๐
It works just like npm
, in the sense that it retrieves packages from the NPM (node package manager) registry, except that npx
will execute node binaries, if any.
Essentially, the command:
- Will pull the code
- Fetch the dependencies and
- Run the binary
Incredibly simple, yet, this same system is being used in more advanced and complex projects.
Creating your ownโ
First, things first:
- Create a folder and go into it,
mkdir card && cd card
- Create a new project,
npm init -y
- Open your new created project in your code editor,
code .
Now that you have a new project, go to package.json
and make sure you have at least the following keys: name, main, bin, author, license
- In
name
, enter the package name (this is the name you will call innpx
) - In
main
andbin
enterindex.js
as value, weโll continue here in the next step - In
author
, enter your name or email, this one is optional, but I guess it doesnโt hurt since your giving out your contact info anyways. - In
license
, go to choosealicense.com and pick one.
package.json
Note that I already have two dependencies, chalk
and boxen
. To install them
Go to your terminal and enter
npm install chalk boxen
- Create a new file
index.js
and open it
As you specified in the package.json
, this is your main
file (entry) / bin
(binary) file.
- To specify that
index.js
is a binary file, start with the following:
node binary
- Add the dependencies you installed earlier
dependencies
- Create an
options
object for the surrounding box
boxen options
- Next, create a
data
object with whatever information you want to include
personal information
- Next, create the
card
There are a lot of ways you can achieve something you like. I found that in my case, this is where I was tweaking the most.
- Finally, log the result to the terminal.
All together
To test your newly created node program,
- Open the terminal and enter
node index.js
Once youโre happy with the result, itโs time to publish it so people can use it through npx
Publishing to NPMโ
The npm
utility has a the command publish
that is pretty self explanatory. The only requirement is that you need an account at NPM. Create your account here
There are a lot of things you can do when publishing to the NPM registry, but these are out of the scope of this tutorial.
Hereโs a great article of how to publish to the npm
- Run
npm publish
and wait for it to finish.
Test it outโ
If all went well,
- Enter
npx <name>
where name is the package name you specified inpackage.json
and thatโs it ! You should see your freshly created npm
card that you can distribute to friends, colleagues and even recruiters.
Repoโ
I purposely used a free to use and distribute license, so go and clone it or fork it and make yours ๐ https://github.com/oschvr/card.