使用vue-element-admin遇到的问题和解决

#问题一

import "core-js/modules/es6.regexp.constructor";
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

SyntaxError: Unexpected string
    at Module._compile (internal/modules/cjs/loader.js:872:18)

解决方法
项目根目录创建
.env.development
加上配置

VUE_CLI_BABEL_TRANSPILE_MODULES = true

问题二

登陆失败

解决方法,在.env.development加上下面配置

VUE_APP_BASE_API = '/api'

问题三

Mac报node-sass版本问题,打包失败!
解决方法:
1)因为node版本和node-sass是有关系的
所以,这种情况下,使用命令,重新安装node-sass就行

npm rebuild node-sass    

问题四

如果问题三解决办法无效,那么有可能你的Mac上,有不同的node版本.
可以统一一下版本,使用brew维护.
删除多余的node

sudo rm -rf /user/local/node

重新使用brew安装node或者升级
安装node

brew install node

升级

brew upgrade node

统一版本后,需要设置node到环境变量里面
使用命令查看node的安装地址

~ » brew list node                                            
/usr/local/Cellar/node/12.10.0/bin/node

配置环境变量,可以在/etc/profile里面配置,或者在.zshrc里面配置
如果在/etc/profile里面配置好了,可是zsh读取不到的话,可以在.zshrc
结尾加一句命令

source /etc/profile
已标记关键词 清除标记
# 下载了vue-element-admin,在本地npm insatall后npm run dev后报错。删除node_modules后重置也不行 C:\Users\Le'novo\Desktop\project\vue-element-admin>npm run dev > vue-element-admin@4.4.0 dev C:\Users\Le'novo\Desktop\project\vue-element-admin > vue-cli-service serve INFO Starting development server... 98% after emitting CopyPlugin DONE Compiled successfully in 23484ms 15:55:03 App running at: - Local: http://localhost:9527/ - Network: unavailable Note that the development build is not optimized. To create a production build, run npm run build. events.js:288 throw er; // Unhandled 'error' event ^ Error: spawn cmd ENOENT at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19) at onErrorNT (internal/child_process.js:469:16) at processTicksAndRejections (internal/process/task_queues.js:84:21) Emitted 'error' event on ChildProcess instance at: at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12) at onErrorNT (internal/child_process.js:469:16) at processTicksAndRejections (internal/process/task_queues.js:84:21) { errno: 'ENOENT', code: 'ENOENT', syscall: 'spawn cmd', path: 'cmd', spawnargs: [ '/c', 'start', '""', '/b', 'http://localhost:9527/' ] } npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! vue-element-admin@4.4.0 dev: `vue-cli-service serve` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the vue-element-admin@4.4.0 dev script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! D:\nodejs\node_cache\_logs\2020-07-02T07_55_03_271Z-debug.log ``` ``` # 报错日志 0 info it worked if it ends with ok 1 verbose cli [ 1 verbose cli 'C:\\Program Files\\nodejs\\node.exe', 1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js', 1 verbose cli 'run', 1 verbose cli 'dev' 1 verbose cli ] 2 info using npm@6.13.4 3 info using node@v12.16.1 4 verbose run-script [ 'predev', 'dev', 'postdev' ] 5 info lifecycle vue-element-admin@4.4.0~predev: vue-element-admin@4.4.0 6 info lifecycle vue-element-admin@4.4.0~dev: vue-element-admin@4.4.0 7 verbose lifecycle vue-element-admin@4.4.0~dev: unsafe-perm in lifecycle true 8 verbose lifecycle vue-element-admin@4.4.0~dev: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\Le'novo\Desktop\project\vue-element-admin\node_modules\.bin;C:\redis;C:\Program Files\nodejs\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\Git\cmd;C:\Program Files\nodejs\node_global;C:\Program Files\nodejs\node_global\node_modules\yarn\bin;C:\Program Files\nodejs\node_global;C:\Program Files\nodejs\node_global\node_modules\cnpm\bin;C:\Users\Le'novo\AppData\Local\Microsoft\WindowsApps;"C:\Users\Le'novo\AppData\Local\Programs\Microsoft VS Code\bin;C:\Program Files\nodejs\node_global\node_modules";C:\redis;C:\Users\Le'novo\AppData\Roaming\npm;C:\Program Files\nodejs\node_global\;C:\Program Files\nodejs\node_modules;C:\Program Files\nodejs\node_global\node_modules\yarn\bin; 9 verbose lifecycle vue-element-admin@4.4.0~dev: CWD: C:\Users\Le'novo\Desktop\project\vue-element-admin 10 silly lifecycle vue-element-admin@4.4.0~dev: Args: [ '/d /s /c', 'vue-cli-service serve' ] 11 silly lifecycle vue-element-admin@4.4.0~dev: Returned: code: 1 signal: null 12 info lifecycle vue-element-admin@4.4.0~dev: Failed to exec dev script 13 verbose stack Error: vue-element-admin@4.4.0 dev: `vue-cli-service serve` 13 verbose stack Exit status 1 13 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16) 13 verbose stack at EventEmitter.emit (events.js:311:20) 13 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14) 13 verbose stack at ChildProcess.emit (events.js:311:20) 13 verbose stack at maybeClose (internal/child_process.js:1021:16) 13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5) 14 verbose pkgid vue-element-admin@4.4.0 15 verbose cwd C:\Users\Le'novo\Desktop\project\vue-element-admin 16 verbose Windows_NT 10.0.17763 17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "dev" 18 verbose node v12.16.1 19 verbose npm v6.13.4 20 error code ELIFECYCLE 21 error errno 1 22 error vue-element-admin@4.4.0 dev: `vue-cli-service serve` 22 error Exit status 1 23 error Failed at the vue-element-admin@4.4.0 dev script. 23 error This is probably not a problem with npm. There is likely additional logging output above. 24 verbose exit [ 1, true ]
©️2020 CSDN 皮肤主题: 黑客帝国 设计师:上身试试 返回首页