Skip to content

shwetd19/creating-npm-package

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Creating Your Own NPX Introduction Command

Crafting a personalized npx introductory command can be an enjoyable and practical endeavor! The npx functionality enables you to execute Node.js-oriented packages without the need for global installation. Below is a sequential tutorial outlining the process of formulating your very own npx introduction command:

Step 1: Choose a Package Name

Decide on a unique name for your package. This name will be used to invoke your introduction command using npx.

Step 2: Create a New Directory

Create a new directory for your package. You can name it after the package name you chose in the previous step.

mkdir get-npx-intro
cd get-npx-intro

Step 3: Initialize Your Package

Initialize your project as a Node.js package using the following command:

npm init -y

Create an Executable Script

Inside your project directory, create a JavaScript file that will serve as the executable script for your npx command. Let's call this file index.js. You can follow my example or edit it accordingly.

Make sure to define bin in 'package.json'

"bin": {
  "my-npx-command": "./index.js"
},

Make the Script Executable

In your terminal, make your script file executable by running:

For Linux

chmod +x index.js

For Windows

Note: git should be installed.

git update-index --chmod=+x index.js

Test your command

  • Link the package using npm link
  • Test by running the command npx package-name
  • If it works as expected, make sure to unlink it using npm unlink -g directory-name

Publish your package

  • Make an npm account
  • Login to your account using the command npm login
  • Publish the package using the command npm publish

Send it to your friends and find a cool way to introduce yourself!

About

Go to your terminal and type `npx shwetas-dhake'

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published