Vue_安装vue脚手架

一、安装nodejs

  1. nodejs官方下载地址:

  2. 在控制台输入下面命令来查看nodejs是否正确安装:
    node -v
    npm -v

  3. 将npm的仓库源由安装时默认的npm源地址设置为淘宝镜像地址(这一步不是必须的,国外的源下载会很慢,只要你慢你就可以换成国内淘宝的源):
    首先用以下命令查看npm的仓库源是设置在哪儿
    npm config get registry
    在这里插入图片描述
    将npm的仓库源改变为国内淘宝镜像的位置
    npm config set registry=https://registry.npmmirror.com

    在nodejs的安装目录下创建全局目录node_global和node缓存文件夹node_cache(这一步可选,如果不创建则nodejs会有默认的文件夹)
    使用npm命令安装模块分为本地安装和全局安装。
    本地安装:npm install express 会安装到当前项目,项目目录下会多一个 node_modules文件夹
    全局安装:npm install express -g 会安装到指定的目录(node_global)

    另外,如果没有创建全局目录node_global,那么全局安装的文件将会保存 到 C:\Users\zhoujie\AppData\Roaming\npm 。如果没有创建node_cache,那么文件将会保存到 C:\Users\zhoujie\AppData\Local\npm-cache。 所以安装好node后,要在nodejs的安装目录下新建node_global和node_cache(node缓存文件夹)。
    在这里插入图片描述

  • 查看npm 全局安装地址
    npm config get prefix
  • 查看npm 缓存位置
    npm config get cache

设置 npm 安装的地址及缓存位置

  • 设置npm安装的地址
    npm config set prefix "C:\1developerkits\nodejs\node_global"
  • npm缓存位置设置
    npm config set cache "C:\1developerkits\nodejs\node_cache"
    在这里插入图片描述

二、安装vue脚手架

前提:电脑上已经安装node.js和npm,由于最新稳定版的node.js已经集成了npm,所以安装node.js也把npm也一并安装好了,但可能不是最新的npm版本。

  1. 全局安装vue脚手架 npm install -g @vue/cli
  • 报错:
    npm ERR! code EPERM
    npm ERR! syscall mkdir
    npm ERR! path C:\1developerkits\nodejs\node_cache_cacache
    npm ERR! errno -4048
    npm ERR! Error: EPERM: operation not permitted, mkdir ‘C:\1developerkits\nodejs\node_cache_cacache’
    npm ERR! [Error: EPERM: operation not permitted, mkdir ‘C:\1developerkits\nodejs\node_cache_cacache’] {
    npm ERR! errno: -4048,
    npm ERR! code: ‘EPERM’,
    npm ERR! syscall: ‘mkdir’,
    npm ERR! path: ‘C:\1developerkits\nodejs\node_cache\_cacache’
    npm ERR! }
    npm ERR!
    npm ERR! The operation was rejected by your operating system.
    npm ERR! It’s possible that the file was already in use (by a text editor or antivirus),
    npm ERR! or that you lack permissions to access it.
    npm ERR!
    npm ERR! If you believe this might be a permissions issue, please double-check the
    npm ERR! permissions of the file and its containing directories, or try running
    npm ERR! the command again as root/Administrator.
    npm ERR! Log files were not written due to an error writing to the directory: C:\1developerkits\nodejs\node_cache_logs
    npm ERR! You can rerun the command with --loglevel=verbose to see the logs in your terminal在这里插入图片描述
  • 报错解决方案:
    法一、用管理员身份打开命令行窗口来解决报错
    法二、修改nodejs安装文件夹的安全权限来解决报错在这里插入图片描述
  • 重新输入全局安装命令 在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

三、创建项目

  1. 使用命令:vue create [options] <app-name>
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
  2. 输入命令:
  • cd vue_test
  • npm run serve
    在这里插入图片描述
  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值