/simple-npm-cli-global

Make a simple global command line interface using node and npm. (Like dcl for decentraland)

Primary LanguageJavaScriptGNU General Public License v3.0GPL-3.0

How to write a NPM CLI package like decentraland npm (dcl)

Use node to create a global command line interface (CLI)

npm install -g <your-package-name>

First Step: Edit package.json

Add "bin" parameter and point to a javascript file, eg: command.js

{
  "name": "mycommand",
  "version": "1.0.0",
  "description": "",
  "main": "cli.js",
  "bin": {
    "mycommand": "cli.js"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

cli.js file should look like this

#!/usr/bin/env node

console.log('hello');