Npm 3 Steps

what is npm :
npm is the package manager for JavaScript. Find, share, and reuse packages of code from hundreds of thousands of developers — and assemble them in powerful new ways.

  • npm 3 things need to remember

    1. npm init

    1
    npm init
    npm will take charge all the files under this directory.
    After this action, you will found there have a [package.json] file appear.
    picture

2. npm install

eg. install jquery:

1
npm install jquery --save

[jquery] is the package name
After this step, a new jquery folder will appear under node-model.
And package.json’s dependencies will add a jquery automqtically.
picture

3. npm run

run task

1
npm run

picture

you can config your package.json’s scripts to run what you want.
Like this:

1
2
3
4
"scripts": {
"test": "echo \"error: no test specified\" && exit 1",
"gulp":"gulp"
}

If you run “npm run gulp”, It is like run gulp on terminal directly.
1
2
3
4
5
6
7
$ npm run gulp 
==
$ gulp

$ npm run test
==
echo \"error: no test specified\" && exit 1