本职后端,最近在弄一个element-plus的前端项目。当我修改env、.env.development等环境变量文件的时候,vite会报错,如下
VITE v5.4.1 ready in 1108 ms
➜ Local: http://localhost:8841/
➜ Network: http://192.168.0.19:8841/
➜ Network: http://172.16.73.1:8841/
➜ Network: http://172.16.56.1:8841/
17:15:30 [vite] .env changed, restarting server...
Error: ENOTEMPTY: directory not empty, rmdir 'D:\frontpro\ad\admin\web\node_modules\.pnpm\[email protected]\node_modules\sass\types\legacy'
^CTerminate batch job (Y/N)? Y
Y
ELIFECYCLE Command failed with exit code 255.
(base)
Administrator@WIN-20230515RJR MINGW64 /d/frontpro/ad/admin/web (main)
$ pnpm dev
> [email protected] dev D:\frontpro\ad\admin\web
> NODE_OPTIONS=--max-old-space-size=4096 vite
error when starting dev server:
Error: Cannot find module 'sass'
Require stack:
- D:\frontpro\ad\admin\web\node_modules\.pnpm\@[email protected]\node_modules\@pureadmin\theme\dist\index.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
at Function.resolve (node:internal/modules/helpers:187:19)
at D:\frontpro\ad\admin\web\node_modules\.pnpm\@[email protected]\node_modules\@pureadmin\theme\dist\index.js:180:34
at Array.map (<anonymous>)
at PluginContext.buildStart (D:\frontpro\ad\admin\web\node_modules\.pnpm\@[email protected]\node_modules\@pureadmin\theme\dist\index.js:177:41)
at PluginContainer.hookParallel (file:///D:/frontpro/ad/admin/web/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/vite/dist/node/chunks/dep-Cy9twKMn.js:48877:39)
at PluginContainer.buildStart (file:///D:/frontpro/ad/admin/web/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/vite/dist/node/chunks/dep-Cy9twKMn.js:48884:12)
at file:///D:/frontpro/ad/admin/web/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/vite/dist/node/chunks/dep-Cy9twKMn.js:63016:23
at initServer (file:///D:/frontpro/ad/admin/web/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/vite/dist/node/chunks/dep-Cy9twKMn.js:63023:6)
at httpServer.listen (file:///D:/frontpro/ad/admin/web/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/vite/dist/node/chunks/dep-Cy9twKMn.js:63031:15)
ELIFECYCLE Command failed with exit code 1.
其他修改不会有任何问题,每次遇到都得把node_modules.pnpm\[email protected]目录删除重新install才行