How to quickly create a node. js Project using Grunt Scaffolding

Source: Internet
Author: User

  Zhanhailiang Date: 2014-11-17

1. Install the NODE.JS,NPM tool (slightly).

2. Install Grunt, Grunt-init

Install - G Install - G grunt-init

3. Download Scaffolding: Grunt-init-node-create a node. js module, including Nodeunit unit tests.

git clone  git  @  github.com:billfeller/ Grunt-init-node.git ~/. Grunt-init/ node 

Note that its default path is ~/.GRUNT-INIT/XXXX, if downloaded to the default path, the subsequent only need to pass grunt-init xxxx can be directly initialized, if downloaded to a private specified path, the grunt-init/path/to/ The template is initialized with an absolute path.

4. Initialize:

[Root@~/Wade/Nodejs/Grunt-init-node-demo]# grunt-init NodeRunning"Init:node" (Init)Taskthis task would create one or MoreFilesinchThe current directory, based in Theenvironment and the answers to a few questions. Note that answering"?"To Anyquestion'll show question-specific Helpand answering"None"To more Questionswill leave its value blank."Node"Template notes:project name shouldn' t contain ' node ' or ' JS ' and should be a unique ID notalready on use at Search.npmjs.org. please answer the Followin G:[?] Project name (Grunt-init-node-demo) [?] Description (the best project ever.) [?] Version (0.1.0) [?] Project git repository (git://github.com/billfeller/grunt-init-node-demo.git) [?] Project homepage (https://github.com/billfeller/grunt-init-node-demo) [?] Project issues Tracker (https://github.com/billfeller/grunt-init-node-demo/issues) [?] Licenses (MIT) [?] Author name (Billfeller) [?] Author email ([email protected]) [?] Author URL (none) http://blog.csdn.net/billfeller[?] What versions of node does it run? (>= 0.8.0) [?] Main Module/entry Point (Lib/grunt-init-node-demo) [?] NPM Test Command (Grunt nodeunit) [?] Would this project being tested with Travis CI? (y/n) Y[?] Do you need to make any changes to the above before continuing? (y/n) N writing. Gitignore. Okwriting. Jshintrc. Okwriting. Travis.yml. Okwriting gruntfile.js ... Okwriting REAdme.md ... Okwriting lib/grunt-init-node-demo.js ... Okwriting test/grunt-init-node-demo_test.js ... Okwriting License-mit ... Okwriting Package.json ... Ok initialized from template "Node". You should now install Project dependencies with NPM install. After the, Youmay execute project tasks with grunt. For more information about Installingand configuring Grunt, please see the Getting Started guide: http://gruntjs.com/ Getting-started done, without errors.

When you see "done, without errors.", it means that the initialization is successful, and then you can start focusing on business development.

Note: If you encounter the following prompt when initializing:

[[Email protected]~/wade/nodejs]# grunt-init noderunning "Init:node" (init) taskthis task would create one or more files in The current directory, based in Theenvironment and the answers to a few questions. Note that answering "?" to Anyquestion would show question-specific help and answering "none" to most questionswill leave I TS value blank. warning:existing files may be overwritten! Use the--force to continue. Aborted due to warnings.

That's because the current directory already has an associated file with the same name, which can be initialized by clearing the relevant file or rebuilding an empty directory.

5. Grunt Official Maintenance several templates:

    • grunt-init-commonjs-create a commonjs module, including Nodeunit unit tests.
    • grunt-init-gruntfile- Create a basic gruntfile.
    • grunt-init-gruntplugin -Create a Grunt plugin, including Nodeunit unit tests.
    • grunt-init-jquery- Create a jQuery plugin, including Qunit unit tests.
    • grunt-init-node- Create a node. js module, including Nodeunit unit tests.

You can refer to the above procedure to initialize the relevant project.

6. Reference:

    • Getting started
    • Project Scaffolding
    • Using Grunt (almost) painless to do front-end development (i)

How to quickly create a node. js Project using Grunt Scaffolding

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.