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 项目名


 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
安装Vue路由,您可以按照以下步骤进行操作: 1. 打开您的项目,然后在项目的根目录下打开命令行或终端。 2. 输入以下命令来安装全局路由: ``` npm install vue-router -S ``` 这将会安装Vue路由插件并将其添加到项目的依赖中。 3. 在项目的`src`目录下创建一个名为`router`的文件夹,并在其中添加一个名为`index.js`的文件。这个文件将作为总路由文件。 4. 在`index.js`文件中,引入Vue和Vue路由插件: ```javascript import Vue from 'vue' import VueRouter from 'vue-router' ``` 5. 使用路由中间件: ```javascript Vue.use(VueRouter) ``` 6. 在`index.js`文件中,定义路由表和路由规则。您可以根据需求自由添加路由规则。例如: ```javascript const index = () => import('../page/index.vue') const routes = [ { path: '/', component: index, meta: { title: '首页' } }, ] ``` 7. 创建一个新的Vue路由实例,并设置路由模式和基本URL: ```javascript const router = new VueRouter({ mode: 'history', base: process.env.BASE_URL, routes }) ``` 8. 在`main.js`文件中引入刚刚创建的`index.js`文件,并将路由实例添加到Vue实例中: ```javascript import router from './router' new Vue({ router, // other configurations }) ``` 9. 在您的`App.vue`文件中,添加路由出口,即 `<router-view></router-view>` 标记。这将作为路由组件的渲染区域,根据URL的不同,不同的组件将会被渲染出来: ```html <template> <div id="app"> <!-- other content --> <router-view></router-view> </div> </template> ``` 这样,您就成功安装了Vue路由,并将其集成到了您的项目中。现在,您可以根据需要定义和使用各种路由规则来实现页面切换和导航功能。<span class="em">1</span><span class="em">2</span><span class="em">3</span><span class="em">4</span>

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值