Vue项目的npm环境搭建

Vue项目的环境搭建主要步骤如下:

vue项目创建

安装NodeJS

  1. +到官网下载自己系统对应的版本,这里我们下载Windows系统的64zip文件,下载完成后解压,可以看到里面有一个node.exe的可执行文件。
  2. +如果你安装的是旧版本的 npm,可以很容易得通过 npm 命令来升级。`npm install npm -g  # windows`

安装 webpack

  1. -安装好 npm 之后,就可以通过 npm 命令来下载各种工具了,安装打包工具 webpack,-表示全局安装。`npm install webpack -g`
  2. +安装 vue-cli

安装 vue-cli

  1. +安装 vue 脚手架项目初始化工具 vue-cli,-表示全局安装。`npm install vue-cli -g`

安装 nrm

  1. +安装 nrm npm下资源控制器工具`npm install nrm -g`查看镜像命令`nrm ls`使用某个为默认镜像的命令`nrm user cnpm`

安装 Yarn

  1. +YarnFacebook发布的 node.js 包管理器,它比 npm 更快、更高效,可以使用Yarn替代 npm `npm i yarn -g --verbose`

创建项目

  1. +环境已经搭建完成,现在我们通过 vue-cli 来生成一个项目,名称为 kitty-ui
  2. +项目创建命令如下`vue init webpack kitty-ui`

 

以下是copy被人的博客,作为记录地址:https://www.cnblogs.com/xifengxiaoma/p/9533018.html#undefined

技术基础

开发之前,请先熟悉下面的4个文档

开发环境

  • Node JS(npm)
  • Visual Studio Code(前端IDE)

安装Visual Studio Code

下载地址: 官网下载地址

Visual Studio Code 是一款非常优秀的开源编辑器,非常适合作为前端IDE, 根据自己的系统下载相应的版本进行安装。

更多 VS Code 教程可以参考以下资料

官网文档:https://code.visualstudio.com/docs

简书教程:https://www.jianshu.com/p/990b19834896

安装NodeJS

下载地址: nodejs中文网

到官网下载自己系统对应的版本,这里我们下载Windows系统的64位zip文件,下载完成后解压,可以看到里面有一个node.exe的可执行文件。

这里写图片描述

把Node添加到系统环境变量里面,打开cmd命令行,输入npm -v,如果出现如下图的显示,说明已经安装正确。

 

如果你安装的是旧版本的 npm,可以很容易得通过 npm 命令来升级。

sudo npm install npm -g #linux
npm install npm -g  # windows

可以看到升级之后,再次执行 npm -v 查看版本已经升级到 6.4.0 了。

更多NodeJS教程可以参考以下资料

中文官网:http://nodejs.cn/api/

菜鸟学堂:https://www.runoob.com/nodejs/nodejs-tutorial.html

安装 webpack

安装好 npm 之后,就可以通过 npm 命令来下载各种工具了。

安装打包工具 webpack,-g 表示全局安装。

npm install webpack -g

更多webpack教程可以参考以下资料

菜鸟学堂:http://www.runoob.com/w3cnote/webpack-tutorial.html

安装 vue-cli

安装 vue 脚手架项目初始化工具 vue-cli,-g 表示全局安装。

npm install vue-cli -g

淘宝镜像

因为 npm 使用的是国外中央仓库,有时候下载速度比较“喜人”,就像 Maven 有国内镜像一样,npm 在国内也有镜像可用。这里建议使用淘宝镜像。

安装淘宝镜像,安装成功后 用 cnpm 替代 npm 命令即可,如: cnpm install webpack -g 。

npm install -g cnpm --registry=https://registry.npm.taobao.org

安装 Yarn

Yarn 是 Facebook 发布的 node.js 包管理器,它比 npm 更快、更高效,可以使用 Yarn 替代 npm 。

如果你安装了node,就安装了npm,可以使用下面的命令来安装:

npm i yarn -g --verbose

npm官方源访问速度实在不敢恭维,建议使用之前切换为淘宝镜像,在yarn安装完毕之后执行如下指令:

yarn config set registry https://registry.npm.taobao.org

到此为止我们就可以在项目中像使用npm一样使用yarn了。

使用 Yarn 跟 npm 差别不大,具体命令关系如下:

复制代码
复制代码
npm install  => yarn install
npm install --save [package] => yarn add [package]
npm install --save-dev [package] => yarn add [package] --dev
npm install --global [package] => yarn global add [package]
npm uninstall --save [package] => yarn remove [package]
npm uninstall --save-dev [package] => yarn remove [package]
复制代码
复制代码

创建项目

环境已经搭建完成,现在我们通过 vue-cli 来生成一个项目,名称为 kitty-ui。

vue init webpack kitty-ui

一路根据提示输入项目信息,等待项目生成。

命令执行完毕,生成项目结构如下

进入到项目根目录,执行  yarn install (也可以用 npm install,或淘宝 cnpm install,我们这里用 yarn 会快一点) 安装依赖包。

cd kitty -ui
yarn install

依赖包安装完成之后,会在项目根目录下生成 node_modules 文件夹,是下载的依赖包的统一存放目录。

安装完成之后,执行应用启动命令,运行项目。

npm run dev

命令执行之后,如果显示 “I Your application is runing here ....”,就表示启动成功了。

浏览器访问对应地址,如这里的: http://localhost:8080,会出现 vue 的介绍页面。

到此,我们的项目脚手架就建立起来了。

vue项目创建

安装NodeJS

  1. +到官网下载自己系统对应的版本,这里我们下载Windows系统的64zip文件,下载完成后解压,可以看到里面有一个node.exe的可执行文件。
  2. +如果你安装的是旧版本的 npm,可以很容易得通过 npm 命令来升级。`npm install npm -g  # windows`

安装 webpack

  1. -安装好 npm 之后,就可以通过 npm 命令来下载各种工具了,安装打包工具 webpack,-表示全局安装。`npm install webpack -g`
  2. +安装 vue-cli

安装 vue-cli

  1. +安装 vue 脚手架项目初始化工具 vue-cli,-表示全局安装。`npm install vue-cli -g`

安装 nrm

  1. +安装 nrm npm下资源控制器工具`npm install nrm -g`查看镜像命令`nrm ls`使用某个为默认镜像的命令`nrm user cnpm`

安装 Yarn

  1. +YarnFacebook发布的 node.js 包管理器,它比 npm 更快、更高效,可以使用Yarn替代 npm `npm i yarn -g --verbose`

创建项目

  1. +环境已经搭建完成,现在我们通过 vue-cli 来生成一个项目,名称为 kitty-ui
  2. +项目创建命令如下`vue init webpack kitty-ui`
posted @   silentmuh  阅读(360)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
阅读排行:
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!
Live2D
欢迎阅读『Vue项目的npm环境搭建』
  1. 1 Walk Thru Fire Vicetone
  2. 2 爱你 王心凌
  3. 3 Inspire Capo Productions - Serenity
  4. 4 Welcome Home Radical Face
  5. 5 粉红色的回忆 李玲玉
Walk Thru Fire - Vicetone
00:00 / 00:00
An audio error has occurred, player will skip forward in 2 seconds.

作词 : Van Der Voort, Joren Johannes

作曲 : Victor Pool/Justin Gammella/Ruben Christopher den Boer/Meron Mengist/Joren van der Voort

Talk to me

Spill the secrets you've been keeping

Life cuts deep

Let me help pick up the pieces

You're not alone, I'm by your side

Don't you know, don't you know

I'll walk through fire with you

I'll walk through fire

No matter what, I'll make it right

Don't you know, don't you know

I'll walk through fire with you

I'll walk through fire

I'm not an angel, I'm not a saint

I've been a closed book full of mistakes

But when you're broken, when you're in pain

Oooh, ooh

I'll walk through fire with you

I'll walk through fire

I'll walk through fire with you

I'll walk through fire

You know I

Don't pretend to be a savior

But let me in, yeah

I promise nobody can break us

You're not alone, I'm by your side

Don't you know, don't you know

I'll walk through fire with you

I'll walk through fire

No matter what, I'll make it right

Don't you know, don't you know

I'll walk through fire with you

I'll walk through fire

I'm not an angel, I'm not a saint

I've been a closed book full of mistakes

But when you're broken, when you're in pain

Oooh, ooh

I'll walk through fire with you

I'll walk through fire with you

I'll walk through fire

I'll walk through fire with you

I'll walk through fire with you

You're not alone, I'm by your side

Don't you know, don't you know

I'll walk through fire with you

I'll walk through fire

I'm not an angel, I'm not a saint

I've been a closed book full of mistakes

But when you're broken, when you're in pain

Oooh, ooh

I'll walk through fire with you

I'll walk through fire with you

I'll walk through fire

I'll walk through fire with you

I'll walk through fire with you

点击右上角即可分享
微信分享提示