0

I have a designed a Node application which is based on yeoman which I want it to distribute it to the user using npm.

The thing is after installing the application using node. I want to user to provide several global commands through which he can have ease using my application easily just like command are provided when using grunt or bower or yeoman.

$ bower install <package-name>
$ grunt serve

Similarly I want my application to provide some command so that user can have ease to handle it. let the command be xyz

$ xyz init #will initialize the application and create the scaffolding.

I already have the application designed on node I just want it to provide the application installation using a global command line.

1 Answer 1

2

Just create a bin script :

package.json :

  "bin": {
    "xyz": "index.js"
  }

index.js :

console.log(process.argv);

Usage :

npm install xyz
xyz foo bar

Outputs :

[ 'node', '/path/to/your/script/file', 'foo', 'bar']

For more information, you can refer to this blog post : Building a simple command line tool with npm

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.