git clone下来的代码工程,然后再vscode里面直接pnpm run dev运行,报错:
'vite' 不是内部或外部命令,也不是可运行的程序或批处理文件。
ELIFECYCLE Command failed with exit code 1.
原因:
下载的工程代码中node_modules中的依赖库存在改变,导致不能执行。
解决:
网上均是说执行npm i即可解决,可是我这里执行后报错:
PS D:\my_workspace\webGL\xxx\gis> npm i
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! node_modules/vite-plugin-ejs
npm ERR! vite-plugin-ejs@"^1.6.4" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR!
npm ERR! C:\Users\xxxx\AppData\Local\npm-cache\_logs\2024-03-22T07_17_58_812Z-debug-0.log
同时使用npm install 也是报同样的错,这里我的处理步骤如下:
1、删除node_modules文件夹
2、执行pnpm i (这个可能和自己电脑上是否安装有关吧)
PS D:\my_workspace\webGL\xxx\gis> pnpm i
Lockfile is up to date, resolution step is skipped
Packages: +488
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Packages are hard linked from the content-addressable store to the virtual store.
Content-addressable store is at: D:\.pnpm-store\v3
Virtual store is at: node_modules/.pnpm╭──────────────────────────────────────────────────────────────────╮
│ │
│ Update available! 8.6.12 → 8.15.5. │
│ Changelog: https://github.com/pnpm/pnpm/releases/tag/v8.15.5 │
│ Run a script from: https://pnpm.io/installation │
│ │
│ Follow @pnpmjs for updates: https://twitter.com/pnpmjs │
│ │
╰──────────────────────────────────────────────────────────────────╯Progress: resolved 488, reused 289, downloaded 199, added 488, done
Downloading registry.npmjs.org/three/0.160.1: 9.41 MB/9.41 MB, done
node_modules/.pnpm/vue-demi@0.14.6_vue@3.3.2/node_modules/vue-demi: Running postinstall script, done in 750msdependencies:
+ @antv/x6 2.14.1
+ @antv/x6-vue-shape 2.1.1
+ @turf/bearing 6.5.0
+ @turf/centroid 6.5.0
+ @turf/distance 6.5.0
+ @turf/helpers 6.5.0
+ @turf/points-within-polygon 6.5.0
+ @turf/random 6.5.0
+ @turf/sector 6.5.0
+ @turf/turf 6.5.0
+ 3d-force-graph 1.73.0
+ axios 1.4.0
+ crypto-js 4.1.1
+ d3 5.16.0
+ docx 8.2.0
+ echarts 5.4.3
+ extendable-media-recorder 8.1.0
+ extendable-media-recorder-wav-encoder 7.0.96
+ file-saver 2.0.5
+ html2canvas 1.4.1
+ jquery 3.5.1
+ js-base64 3.7.5
+ mitt 3.0.1
+ moment 2.29.4
+ relation-graph 2.0.27
+ rollup 2.42.0
+ three 0.160.1
+ three-spritetext 1.8.1
+ vue-router 4.2.0
+ vue3-print-nb 0.1.4devDependencies:
+ @arco-design/web-vue 2.46.0
+ @types/node 18.16.9
+ @vitejs/plugin-vue 4.2.3
+ autoprefixer 10.4.14
+ less 4.2.0
+ mockjs 1.1.0
+ postcss 8.4.23
+ tailwindcss 3.3.2
+ vite 4.3.5
+ vite-plugin-mock 2.9.8Done in 27.9s
3、再次执行pnpm run dev即可以了