Socket
Book a DemoInstallSign in
Socket

whats-the-weather

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

whats-the-weather

A simple node CLI example

1.0.7
latest
npmnpm
Version published
Maintainers
1
Created
Source

Creating a command line utility

Creating a node CLI utility is really easy, If you have a basic knowledge of javascript and node you will already know how to write one.

  • To get started create a new folder and run npm init. Fill out the options.
  • Open the newly created package.json and add the following:
"bin": {
  "<name of package>": "./index.js"
}
  • Make sure you replace <name of package> with the name of your package.
  • Create an index.js file and add #!/usr/bin/env node on the first line.
  • To install the CLI utility run npm install -g. This will allow you to run your CLI globally.
  • You can also run npm link, This will bind your local package to the global install so you don't have to reinstall your utility every time you make a change. Run npm unlink to remove the link again.
  • When you are happy with your package you can publish it to http://npmjs.com by running npm publish. Every time you wish to make a change you will need to increase the version number in package.json.

You can now start creating your CLI Utility. Browse the files in this package to find out how everything works.

scripting-with-node - A fantastic article for getting started.

FAQs

Package last updated on 01 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.