系统环境#
- Windows 10 / Windows 11
- Node v20.10.0
- “vue”: “3.5.13”
- “vite”: “6.1.0”
- “tsx”: “4.19.2”,
问题表现#
> vite build --mode prod
Building [████████████████████████░░░░░░░░░░░░░░░░] 60% | Time: 5.6s
Build failed. Please check the error message
error during build:
[vite:vue-jsx] Cannot find package 'D:\code\graduation-design\code\project-vue\soybean-admin-antd\node_modules\.pnpm\@[email protected][email protected]_@[email protected][email protected][email protected][email protected]_eu2zzdc4k7cexl2tg3rvqfswxm\node_modules\@babel\plugin-transform-typescript\package.json' imported from D:\code\graduation-design\code\project-vue\soybean-admin-antd\node_modules\.pnpm\@[email protected][email protected]_@[email protected][email protected][email protected][email protected]_eu2zzdc4k7cexl2tg3rvqfswxm\node_modules\@vitejs\plugin-vue-jsx\dist\index.mjs
Did you mean to import @[email protected]_@[email protected]/node_modules/@babel/plugin-transform-typescript/lib/index.js?
file: D:/code/graduation-design/code/project-vue/soybean-admin-antd/src/views/manage/menu/index.vue?vue&type=script&setup=true&lang.tsx
at legacyMainResolve (node:internal/modules/esm/resolve:205:26)
at packageResolve (node:internal/modules/esm/resolve:831:14)
at moduleResolve (node:internal/modules/esm/resolve:901:20)
at defaultResolve (node:internal/modules/esm/resolve:1121:11)
at nextResolve (node:internal/modules/esm/hooks:865:28)
at resolve (file:///D:/code/graduation-design/code/project-vue/soybean-admin-antd/node_modules/.pnpm/[email protected]/node_modules/tsx/dist/esm/index.mjs?1745914357203:2:4365)
at nextResolve (node:internal/modules/esm/hooks:865:28)
at resolve (file:///D:/code/graduation-design/code/project-vue/soybean-admin-antd/node_modules/.pnpm/[email protected]/node_modules/tsx/dist/esm/index.mjs?1745914357321:2:4365)
at nextResolve (node:internal/modules/esm/hooks:865:28)
at Hooks.resolve (node:internal/modules/esm/hooks:303:30)
ELIFECYCLE Command failed with exit code 1.
解决方案#
换电脑的时候放到了目录更浅的文件夹
,然后正常执行了;
然后原环境换了也方到目录更浅的文件夹,也正常打包了……
原理#
后来连同 node_modules 复制到其他文件夹的时候 Windows 出现
应该就是Windows的问题了