Hemanth's Scribes

web

Node Packing Made Easy With Grunt

Author Photo

Hemanth HM

Thumbnail

Node Packing Made Easy With Grunt

Publish node packages with npm is easier done than said! ;) First of all check out Hitchhikers guide to npm

After which, install grunt! npm install -g grunt and then the fun begins.

Below is a simple example of how to publish node packages with grunt+npm :


$ mkdir test # Replace it with your package name.

$ grunt init:node Running "init:node" (init) task This task will create one or more files in the current directory, based on the environment and the answers to a few questions. Note that answering "?" to any question will show question-specific help and answering "none" to most questions will leave its value blank.

"node" template notes: Project name shouldn't contain "node" or "js" and should be a unique ID not already in use at search.npmjs.org.

Please answer the following: [?] Project name (test) [?] Description (The best project ever.) [?] Version (0.1.0) [?] Project git repository (git://github.com/hemanth/test.git) [?] Project homepage (https://github.com/hemanth/test) [?] Project issues tracker (https://github.com/hemanth/test/issues) [?] Licenses (MIT) [?] Author name (Hemanth.HM) [?] Author email ([email protected]) [?] Author url (none) h3manth.com [?] What versions of node does it run on? (>= 0.6.0) [?] Main module/entry point (lib/test) [?] Npm test command (grunt test) [?] Do you need to make any changes to the above before continuing? (y/N) n

Writing .npmignore...OK Writing grunt.js...OK Writing lib/test.js...OK Writing README.md...OK Writing test/test_test.js...OK Writing LICENSE-MIT...OK

Initialized from template "node".

$ tree . ├── LICENSE-MIT ├── README.md ├── grunt.js ├── lib │ └── test.js ├── npm-debug.log ├── package.json └── test
    
    
    └── test_test.js
    

2 directories, 7 files

$ npm publish #Ofcourse, after editing the boiler code as per need. ```

_WISH :_ Debian packaging was as easy as this!

_Built-in tasks_ As of now, grunt has the following predefined tasks that you can use in your project:

  * [concat](/new/gruntjs/grunt/blob/master/docs/task_concat.md) \- Concatenate files.
  * [init](/new/gruntjs/grunt/blob/master/docs/task_init.md) \- Generate project scaffolding from a predefined template.
  * [lint](/new/gruntjs/grunt/blob/master/docs/task_lint.md) \- Validate files with [JSHint][jshint].
  * [min](/new/gruntjs/grunt/blob/master/docs/task_min.md) \- Minify files with [UglifyJS][uglify].
  * [qunit](/new/gruntjs/grunt/blob/master/docs/task_qunit.md) \- Run [QUnit][qunit] unit tests in a headless [PhantomJS][phantom] instance.
  * [server](/new/gruntjs/grunt/blob/master/docs/task_server.md) \- Start a static web server.
  * test - Run unit tests with [nodeunit][nodeunit].
  * watch - Run predefined tasks whenever watched files change.

Happy Hacking! :)
#javascript#linux
Author Photo

About Hemanth HM

Hemanth HM is a Sr. Machine Learning Manager at PayPal, Google Developer Expert, TC39 delegate, FOSS advocate, and community leader with a passion for programming, AI, and open-source contributions.