Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why does npm init actually initialize a grunt project?

I'm trying very hard to understand the Node ecosystem and how npm and its packages work together and I find it very odd that npm init initializes a "grunt project" and adds a package.json file to your directory.

Since the node package manager manages many different "packages", I would expect something more like npm grunt init

Can anyone fill me in on what's going on here and what makes grunt so special that it gets to be the main npm init command?

** IMPORTANT NOTE ** after studying and understanding all this a lot better, I would strongly recommend you use neither Grunt NOR Gulp and instead take out the middle man and use npm scripts for your front-end build needs. See this great article by Cory House for more information

like image 263
Brian FitzGerald Avatar asked Jun 21 '13 16:06

Brian FitzGerald


People also ask

What does npm init actually do?

The “npm init” command will initialize a project and create the package. json file. There are a few questions asked by NPM each time the “init” command is run so Kent demonstrates how to update the . npmrc file with pre-populated default values.

Is npm init necessary?

It is not required. You can install packages without, and everything will work. npm init can do basically two things: ask for basic project info to include in packages.

What is npm INIT flag?

The npm init command is a step-by-step tool to scaffold out your project. It will prompt you for input for a few aspects of the project in the following order: The project's name. The project's initial version. The project's description.

What does it mean -- save Dev?

--save-dev saves the name and version of the package being installed in the dev-dependency object.


1 Answers

All npm init does is give you prompts (see below) to create a package.json, there's nothing grunt-related that comes with it.

name: (test) 
version: (0.0.0) 
description:
entry point: (index.js) 
test command: 
git repository: 
keywords: 
author: 
license: (BSD) 

Grunt can certainly (and probably should be) installed with npm but it's definitely not part of initializing your package.json.

You can read more about package.json here.

like image 145
imjared Avatar answered Oct 22 '22 10:10

imjared