npm最基本安装

目录

初始化安装

安装gulp

连接到gulp

上传项目到gulp

下载项目


初始化安装


在自己新建的文件夹内用cmd运行
npm init 

$ 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>` afterwards to install a package and
save it as a dependency in the package.json file.

Press ^C at any time to quit.
package name: (demo1)
version: (1.0.0)
description: 新建测试版本
entry point: (index.js)
test command:
git repository:
keywords:
author: cjj
license: (ISC) MIT
About to write to D:\node\initNode\demo1\package.json:

{
  "name": "demo1",
  "version": "1.0.0",
  "description": "新建测试版本",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "cjj",
  "license": "MIT"
}


Is this ok? (yes)

这样就创建完成了(新建完后会自动有一个package.json)

安装gulp

npm install gulp  //只是纯粹的安装gulp
npm install gulp --sava //安装gulp并添加依赖(package.json配置)
npm install gulp --save-dev //安装gulp添加依赖,若别人下载本项目,gulp不会被一起下载
npm install gulp gulp -cli -g //全局安装gulp,并安装gulp手脚架(允许直接使用gulp指令)

连接到gulp


gulp可以上传项目到网站上保存(www.npmjs.com)也跟github一样需要注册
需要你输入用户名和密码以及注册邮箱,登陆成功后可以用
这句指令先登陆连接到服务器

npm adduser


上传项目到gulp

npm publish

这指令(需要在项目文件夹下)即可上传到服务器,需要注意的,其会根据package.json内的name(key名)来作为项目名,而且服务器内的项目名有唯一性,如果gulp服务器已存在同名的项目,那么是不会允许你上传的,需要你更改名字后才允许上传

下载项目

npm install 项目名


 

猜你喜欢

转载自blog.csdn.net/chijiajing/article/details/83012295