首页 > Web开发 > 详细

[Node.js] npm init && npm install

时间:2014-12-09 07:04:49      阅读:565      评论:0      收藏:0      [点我收藏+]

npm init:

For create package.json file which will recode the dependence.

 

npm install:

You can also write like:

npm i 

This is a shortcut way to write npm install.

 

For example. we want to install undersocre.js

npm install -S underscore

The way ‘-S‘ works is it will write down the dependence into the package.json we just create:

{
  "name": "commonJSBroswerfiy",
  "version": "0.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "MIT",
  "dependencies": {
    "underscore": "^1.7.0"
  }
}

 

dev-dependence:

npm install -D bower

‘-D‘ is to add dependence into devdependence which only available for the co-work.

{
  "name": "commonJSBroswerfiy",
  "version": "0.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "MIT",
  "dependencies": {
    "underscore": "^1.7.0"
  },
  "devDependencies": {
    "bower": "^1.3.12"
  }
}

 

If we have package.json, other people download our project and they just need to run:

npm i

They can install all the dependence.

 

[Node.js] npm init && npm install

原文:http://www.cnblogs.com/Answer1215/p/4152373.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!