首页 > 代码库 > [Node.js] npm init && npm install
[Node.js] npm init && npm install
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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。