AngularJS 1.x系列:Node.js安装及npm常用命令(1)
2017-05-27 08:28
676 查看
1. Node.js安装
1.1 Node.js下载
Node.js官网:https://nodejs.org当前下载版本(含npm):Latest LTS Version: v6.10.3 (includes npm 3.10.10)
1.2 Node.js及npm查看版本
安装Node.js之后,查看Node.js及npm版本。node -v
npm -v
2. npm常用命令
npm(node package manager),node包管理器,主要功能是管理node包,包括:安装、卸载、更新、查看、搜索、发布等。npm官网文档:https://docs.npmjs.com/
2.1 npm配置
npm install -g cnpm --registry=https://registry.npm.taobao.org
2.2 npm包管理
◊ npm init:在项目中引导创建一个package.json文件npm init [-f|--force|-y|--yes]
PS F:\Projects\Libing.Portal> npm init This utility will walk you through creating a package.json file. It only covers the most common items, and tries to guess sensible defaults. See `npm help json` for definitive documentation on these fields and exactly what they do. Use `npm install <pkg> --save` afterwards to install a package and save it as a dependency in the package.json file. Press ^C at any time to quit. name: (Libing.Portal) libing.portal version: (1.0.0) description: entry point: (index.js) main.js test command: git repository: keywords: author: libing license: (ISC) MIT About to write to F:\Projects\Libing.Portal\package.json: { "name": "libing.portal", "version": "1.0.0", "description": "", "main": "main.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "libing", "license": "MIT" } Is this ok? (yes)
◊ npm install:安装包
npm install命令参数形式:
npm install --help
npm install (with no args, in package dir) npm install [<@scope>/]<pkg> npm install [<@scope>/]<pkg>@<tag> npm install [<@scope>/]<pkg>@<version> npm install [<@scope>/]<pkg>@<version range> npm install <folder> npm install <tarball file> npm install <tarball url> npm install <git:// url> npm install <github username>/<github project> aliases: i, isntall common options: [--save|--save-dev|--save-optional] [--save-exact]
示例:
npm install angular
运行之后将创建文件夹node_modules,默认安装包最新版本。
指定安装包版本:
npm install angular@1.2.32
-S, --save 安装包信息将加入到dependencies(生产阶段的依赖):
npm install angular -S
"dependencies": { "angular": "^1.6.4" },
-D, --save-dev 安装包信息将加入到devDependencies(开发阶段的依赖):
npm install angular -D
"devDependencies": { "angular": "^1.6.4" }
安装包的依赖都被写入了package.json文件后,可以使用npm install根据dependencies配置安装全部依赖包。
npm install
◊ npm uninstall:卸载包
npm uninstall命令参数形式:
npm uninstall -help
npm uninstall [<@scope>/]<pkg>[@<version>]... [--save|--save-dev|--save-optional]
npm uninstall angular -S
◊ npm list:查看全部已安装包
npm list
◊ npm outdated检查包是否过时
npm outdated
◊ npm update:更新包
npm update [-g] [<pkg>...]
◊ npm view:查看包的注册信息
npm view [<@scope>/]<pkg>[@<version>] [<field>[.subfield]...]
npm view angular
npm view angular dependencies:查看包的依赖关系
npm view angular repository.url:查看包的源文件地址
相关文章推荐
- 安装NodeJS & npm + npm常用命令
- nodejs+express工程 在npm install之后或使用npm install bootstrap命令安装bootstrap之后
- node.js npm常用命令
- nodejs npm常用命令
- node.js常用npm命令
- 【深入浅出Node.js系列二】Node.js&NPM的安装与配置
- Node.js中npm常用命令大全
- Node.js安装及常用命令(Mac OS )
- Node.js 的安装和控制台命令——Node.js摸石头系列
- Node.js 的安装和控制台命令——Node.js摸石头系列之一
- Node.js中npm常用命令大全
- 夺命雷公狗---node.js---2node.js中的npm的常用命令
- Node.js中npm常用命令大全
- linux上安装node.js ,npm,与karma--angularJS环境搭建
- nodejs npm常用命令
- Node.js-npm【1】-常用命令
- centos 5.4 安装nodejs + npm
- node.js&npm的安装和配置
- Java学习系列(一)Java的运行机制、JDK的安装配置及常用命令详解
- 深入浅出Node.js(二):Node.js&NPM的安装与配置