2
I am learning how to create a tool CLI (Command-Line Interface Applications)
and carried out the following steps:
I created a folder and inside it in the terminal
npm init--yes
with that I generated the package.json
in this folder I created a bin folder and inside it an index.js file
after that I arranged package.json so that it becomes index.js as a executable by the command forecast
{
"name": "tableless-cli",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"bin": {
"forecast": "./bin/index.js"
}
}
I put this code in index.js
#! /usr/bin/env node
var https = require('https')
var arguments = process.argv.splice(2, process.argv.length -1).join(' ')
console.log(arguments);
at the terminal I circled:
npm link
forecast
to transform into executable and forecast is what I defined in package.json
I opened the cmd went in the folder at the place where you have package.json and rodei forecast test and error. says that forecast is an invalid command, where I am missing?