一,搭建Vue的环境
1.安装全局的脚手架
npm install -g @vue/cli (vue-cli3)
2.检查是否安装成功
npm -v
二、创建项目
1.首先打开PowerShell ,在你新建文件夹中选中电脑Shift健加上鼠标右键
(一)在此途中遇到一个问题
(1)、执行:get-ExecutionPolicy,回复Restricted,表示状态是禁止的
(2)、执行:set-ExecutionPolicy RemoteSigned即可选择Y
1.vue create new-project( new-project 是项目名)创建项目,之后选择创建Vue2还是Vue3或者是手动配置(根据自己进行选择)在创建项目名称的时候不要有大写字母、中文以及特殊符号
(二)第二个问题没有安装淘宝镜像
当然出现这种问题也不一定是没有安装淘宝镜像的问题。到时候在查查看吧我看其他博主有8个解决这种问题的办法。
(1)在安装淘宝镜像的时候也会出现问题,常见问题就是npm没有权限
npm ERR! code EPERM npm ERR! syscall open npm ERR! path C:\Program Files\nodejs\node_cache\_cacache\tmp\9600794e npm ERR! errno -4048 npm ERR! Error: EPERM: operation not permitted, open 'C:\Program Files\nodejs\node_cache\_cacache\tmp\9600794e' npm ERR! [OperationalError: EPERM: operation not permitted, open 'C:\Program Files\nodejs\node_cache\_cacache\tmp\9600794e'] { npm ERR! cause: [Error: EPERM: operation not permitted, open 'C:\Program Files\nodejs\node_cache\_cacache\tmp\9600794e'] { npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'open', npm ERR! path: 'C:\\Program Files\\nodejs\\node_cache\\_cacache\\tmp\\9600794e' npm ERR! }, npm ERR! isOperational: true, npm ERR! stack: "Error: EPERM: operation not permitted, open 'C:\\Program Files\\nodejs\\node_cache\\_cacache\\tmp\\9600794e'", npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'open', npm ERR! path: 'C:\\Program Files\\nodejs\\node_cache\\_cacache\\tmp\\9600794e' 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.
解决办法用了很多 具体那个起作用不是很明确^^
1、打开你nodejs所在的文件夹中---选择nodejs文件点击右键选择属性---选择安全---选择较长的users和users----选中编辑将所有的权限都允许访问
2、打开你的cmd选择用管理员身份打开输入两行创建文件夹的命令
npm config set prefix "D:\Coding_tools\Nodejs\node_global" npm config set cache "D:\Coding_tools\Nodejs\node_cache"
然后打开环境配置,点击我的电脑右击选择属性---选择高级系统设置---高级--环境配置
在上下两个path中选中编辑将两个文件夹的路径添加进去
3.就是很简单的直接使用管理员身份打开你的cmd然后输入淘宝镜像(但是一般效果不是很明显针对于我^^)
之后再打开你创建项目的文件夹中按住Shift加鼠标右击选择PowerShell。输入淘宝镜像的命令
临时配置
npm --registry https://registry.npm.taobao.org install express
直接配置
npm config set registry https://registry.npm.taobao.org
配置完成之后查看是否配置完成
npm config get registry
npm info express
言归正传开始创建项目命令就在第一步直接输入命令以及项目名称就好
创建好的目录文件
启动项目
输入命令 npm run serve
以上就是咱们的项目创建过程以及遇到的一些问题和解决办法,当然每位小伙伴也不一定会遇到以上问题有可能一下子就创建好了。也有可能会遇到博主没有遇见到的问题加油吧小伙伴们!!!