一、vue3项目创建完后报错
'大事件管理系统\vue3_pinia_demo\node_modules\.bin\' 不是内部或外部命令,也不是可运行的程序 或批处理文件。 node:internal/modules/cjs/loader:998 throw err; ^ Error: Cannot find module 'D:\桌面\yy\各种学习笔记\前端\5.vue2+vue3全套\code\vite\bin\vite.js'
解决办法:
看到一个兄弟的帖子,原来是我路径上的目录名字有&符号,导致无法运行,把&符号删除就可以了,太感谢那位兄弟了。那位兄弟帖子:Error: Cannot find module ‘D:\项目\vite\bin\vite.js‘_error: cannot find module 'vite-CSDN博客
二、npm install -g pnpm报错,npm install pnpm成功但是执行pnpm -v时报错
npm ERR! code EPERM
npm ERR! syscall mkdir
npm ERR! path C:\Program Files\nodejs\node_cache\_cacache
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, mkdir 'C:\Program Files\nodejs\node_cache\_cacache'
npm ERR! [OperationalError: EPERM: operation not permitted, mkdir 'C:\Program Files\nodejs\node_cache\_cacache'] {
npm ERR! cause: [Error: EPERM: operation not permitted, mkdir 'C:\Program Files\nodejs\node_cache\_cacache'] {
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'mkdir',
npm ERR! path: 'C:\\Program Files\\nodejs\\node_cache\\_cacache'
npm ERR! },
npm ERR! isOperational: true,
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'mkdir',
npm ERR! path: 'C:\\Program Files\\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.
解决办法:尝试了改变环境变量之类的都没办法,最后发现是因为node版本太低,无法兼容导致的,更新node版本并且下载目录默认c盘就可以了
三、使用封装的请求接口请求数据时,发现请求路径不是设置的基地址路径,而是主机的路径
检查了封装的api文件以及导入的request文件,基路径没有写错,代码也没有写错,在网上查询了很久,突然发现我的基路径名称是大写的BaseURL,(为什么会是大写,因为小白我一直以为这个基路径是自己创建的普通变量名,结果是vue规定的变量名),然后问题就找到了。一定注意baseURL不要写成BaseURL !!
四、Element-plus的ElMessage.success和ElMessage.err没有显示
我是全局下载pnpm add Element-plus,然后在需要用到ElMessage.success的文件按需导入ElMessage,结果显示不出来,查了一下,发现要在main.js导入它的样式文件才可以使用:
或者,把你导入的那行 import {Elemessage} from 'Element-plus' 删掉,直接使用就可以了