赞
踩
在cloen下载vue3项目,npm i 完成后,npm run serve 报以下错误信息
- $ npm run serve
-
- > vben-admin@2.8.0 serve D:\gongfeng\tz-sale-web
- > npm run dev
-
-
- > vben-admin@2.8.0 dev D:\gongfeng\tz-sale-web
- > vite
-
- failed to load config from D:\gongfeng\tz-sale-web\vite.config.ts
- error when starting dev server:
- TypeError: Cannot read property 'endsWith' of undefined
- at configHtmlPlugin (D:\gongfeng\tz-sale-web\vite.config.ts:375:34)
- at createVitePlugins (D:\gongfeng\tz-sale-web\vite.config.ts:697:20)
- at vite_config_default (D:\gongfeng\tz-sale-web\vite.config.ts:781:14)
- at loadConfigFromFile (D:\gongfeng\tz-sale-web\node_modules\vite\dist\node\chunks\dep-689425f3.js:61937:15)
- at processTicksAndRejections (internal/process/task_queues.js:93:5)
- at async resolveConfig (D:\gongfeng\tz-sale-web\node_modules\vite\dist\node\chunks\dep-689425f3.js:61456:28)
- at async createServer (D:\gongfeng\tz-sale-web\node_modules\vite\dist\node\chunks\dep-689425f3.js:60111:20)
- at async CAC.<anonymous> (D:\gongfeng\tz-sale-web\node_modules\vite\dist\node\cli.js:688:24)
- npm ERR! code ELIFECYCLE
- npm ERR! errno 1
- npm ERR! vben-admin@2.8.0 dev: `vite`
- npm ERR! Exit status 1
- npm ERR!
- npm ERR! Failed at the vben-admin@2.8.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! C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2022-10-25T03_00_16_960Z-debug.log
- npm ERR! code ELIFECYCLE
- npm ERR! errno 1
- npm ERR! vben-admin@2.8.0 serve: `npm run dev`
- npm ERR! Exit status 1
- npm ERR!
- npm ERR! Failed at the vben-admin@2.8.0 serve 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! C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2022-10-25T03_00_16_996Z-debug.log
重新npm i 依旧报错,最后想到使用yarn来安装试试。
- $ yarn
- yarn install v1.22.17
- info No lockfile found.
- warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix
- package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
- [1/5] Validating package.json...
- [2/5] Resolving packages...
- warning conventional-changelog-cli > tempfile > uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
- warning vite-plugin-imagemin > imagemin-gifsicle > gifsicle@5.3.0: [WARNING] Use 5.2.1 instead of 5.3.0, reason: https://github.com/imagemin/gifsicle-bin/issues/133
- warning vite-plugin-imagemin > imagemin-optipng > exec-buffer > tempfile > uuid@3.4.0: Please upgrade to version 7 or higher.
- Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
- warning vite-plugin-imagemin > imagemin-svgo > svgo > stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
- warning vite-plugin-svg-icons > svg-baker > micromatch > snapdragon > source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
- warning vite-plugin-svg-icons > svg-baker > micromatch > snapdragon > source-map-resolve > resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
- warning vite-plugin-svg-icons > svg-baker > micromatch > snapdragon > source-map-resolve > source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
- warning vite-plugin-svg-icons > svg-baker > micromatch > snapdragon > source-map-resolve > urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
- warning vue-tsc > vscode-vue-languageservice@0.29.8: WARNING: This project has been renamed to @volar/vue-language-service. Install using @volar/vue-language-service instead.
- warning vue-tsc > vscode-vue-languageservice > @volar/html2pug@0.29.8: WARNING: This project has been renamed to @johnsoncodehk/html2pug. Install using @johnsoncodehk/html2pug instead.
- warning vue-tsc > vscode-vue-languageservice > vscode-pug-languageservice@0.29.8: WARNING: This project has been renamed to @volar/pug-language-service. Install using @volar/pug-language-service instead.
- warning vue-tsc > vscode-vue-languageservice > vscode-typescript-languageservice@0.29.8: WARNING: This project has been renamed to @volar/typescript-language-service. Install using @volar/typescript-language-service instead.
- [3/5] Fetching packages...
- error @typescript-eslint/eslint-plugin@5.41.0: The engine "node" is incompatible with this module. Expected version "^12.22.0 || ^14.17.0 || >=16.0.0". Got "14.16.1"
- error Found incompatible module.
- info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
还是报错,但是这次的报错就很明确了,node版本不对,必须大于16.0.0
切换nvm的node版本。从14.16.1改为116.13.2
重新yarn,没有报错
yarn serve依旧报错
百度了一下发现endsWidth是js的写法,我就搜有没有例外的写法,果然黄天不负苦心人,搜到了 'abcdef'.split("f").slice(-1)[0] === "" 这种判断方法
- "被查询字符串".split("结尾字符串").slice(-1)[0] === ""
-
- 例如:
- 'abcdef'.split("g").slice(-1)[0] === "";//false
- 'abcdef'.split("abcde").slice(-1)[0] === "";//false
- 'abcdef'.split("f").slice(-1)[0] === "";//true
- 'abcdef'.split("def").slice(-1)[0] === "";//true
-
- 例如判断格式exe
- "文.件.名.exe".split('.').slice(-1)[0] === "exe"//true
- "文.exe.件.名".split('.').slice(-1)[0] === "exe"//false
- "文.件.名exe.".split('.').slice(-1)[0] === "exe"//false
- "文件名.exe.abc.exe.abc".split('.').slice(-1)[0] === "exe"//false
但是还在报错,我就猜测不是方法的问题,是前面值的问题,增加了一个 '?' 就不报错了。
欧克了,兄弟们,曲折啊,前进的道路上几多崎岖啊。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。