vue在乌班图下搭建项目

npm搭建项目

安装nodejs

nodejs下集成了npm。

nodejs建议用apt安装,这样安装方式可以减少配置环境变量的环节,后续安装插件也更方便。

首先设置下载什么版本。

curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -

这里下载的是nodejs14的版本,这个版本根据网上统计,用的人是最多的。

但是建议下载nodejs20的版本,因为最新的npm支持nodejs18~nodejs20,nodejs14有点落后了。

遇到如下界面等待一段时间就可以了。

================================================================================
================================================================================

                              DEPRECATION WARNING

  Node.js 14.x is no longer actively supported!

  You will not receive security or critical stability updates for this version.

  You should migrate to a supported version of Node.js as soon as possible.
  Use the installation script that corresponds to the version of Node.js you
  wish to install. e.g.

   * https://deb.nodesource.com/setup_16.x — Node.js 16 "Gallium"
   * https://deb.nodesource.com/setup_18.x — Node.js 18 LTS "Hydrogen" (recommended)
   * https://deb.nodesource.com/setup_19.x — Node.js 19 "Nineteen"
   * https://deb.nodesource.com/setup_20.x — Node.js 20 "Iron" (current)

  Please see https://github.com/nodejs/Release for details about which
  version may be appropriate for you.

  The NodeSource Node.js distributions repository contains
  information both about supported versions of Node.js and supported Linux
  distributions. To learn more about usage, see the repository:
    https://github.com/nodesource/distributions

================================================================================
================================================================================

Continuing in 20 seconds ...


================================================================================
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
================================================================================

                           SCRIPT DEPRECATION WARNING


  This script, located at https://deb.nodesource.com/setup_X, used to
  install Node.js is deprecated now and will eventually be made inactive.

  Please visit the NodeSource distributions Github and follow the
  instructions to migrate your repo.
  https://github.com/nodesource/distributions

  The NodeSource Node.js Linux distributions GitHub repository contains
  information about which versions of Node.js and which Linux distributions
  are supported and how to install it.
  https://github.com/nodesource/distributions


                          SCRIPT DEPRECATION WARNING

================================================================================
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
================================================================================

如果是第一次使用apt,需要更新一下apt的源。

sudo apt update

然后安装nodejs。

sudo apt install -y nodejs

这里的-y是按照默认方式安装,不加也可以。

验证是否安装成功

验证nodejs版本号

node -v

验证npm版本号

npm -v

有数据输出就是正确安装了

更新npm

首先安装n工具

npm install -g n

更换npm的源为淘宝的源,npm默认用国外的源,下载很慢,网速不好时根本没法下载。

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

更新npm,用的是nodejs14的可以不用更新,因为最新版需要nodejs18~20。

sudo npm install npm -g

意外情况解决

如果nodejs14更新了npm,在查看版本时就会一直报错。

npm WARN notsup Unsupported engine for npm@10.2.5: wanted: {"node":"^18.17.0 || >=20.5.0"} (current: {"node":"14.21.3","npm":"6.14.18"})

这个时候可以更新nodejs到20。

sudo n stable

安装vue脚手架

npm install -g vue-cli

这里安装的是vue2的脚手架。

安装的时候可能进度条会停住,这时需要按回车键。所以安装的时候要看着点。

验证是否安装成功

vue --version

有版本号出现即是安装成功。

创建项目

到你希望保存项目的文件夹。

输入创建vue项目框架的命令。

vue init webpack <ProjectName>

ProjectName就是项目名称,不能有大写字母!!!

然后一路回车,项目就创建好了。

  • 9
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值