您的位置:首页 > 科技 > IT业 > [vite] Pre-transform error: Cannot find package pnpm路径过长导致运行报错

[vite] Pre-transform error: Cannot find package pnpm路径过长导致运行报错

2024/11/18 6:11:42 来源:https://blog.csdn.net/qq_25996219/article/details/140328092  浏览:    关键词:[vite] Pre-transform error: Cannot find package pnpm路径过长导致运行报错

下了套vue3的代码,执行pnpm install初始化,使用vite启动,启动后访问就会报错

报错信息

 ERROR  16:40:53 [vite] Pre-transform error: Cannot find package 'E:\work\VSCodeProjectWork\jeecg\xxxxxxxxx-next\xxxxxxxxx-next-jeecgBoot-vue3\node_modules\.pnpm\@vitejs+plugin-vue-jsx@https+++registry.npmmirror.com+@vitejs+plugin-vue-jsx+-+plugin-vue-jsx_wpfjsfrcyfhppiaqhs2qki2ffu\node_modules\@babel\plugin-transform-typescript\package.json' imported from E:\work\VSCodeProjectWork\jeecg\xxxxxxxxx-next\xxxxxxxxx-next-jeecgBoot-vue3\node_modules\.pnpm\@vitejs+plugin-vue-jsx@https+++registry.npmmirror.com+@vitejs+plugin-vue-jsx+-+plugin-vue-jsx_wpfjsfrcyfhppiaqhs2qki2ffu\node_modules\@vitejs\plugin-vue-jsx\dist\index.cjs
Did you mean to import @babel+plugin-transform-typescript@https+++registry.npmmirror.com+@babel+plugin-transform-typ_t6dvr774uyzoiatluosu5niumu/node_modules/@babel/plugin-transform-typescript/lib/index.js?ERROR  16:41:02 [vite] Internal server error: Cannot find package 'E:\work\VSCodeProjectWork\jeecg\xxxxxxxxx-next\xxxxxxxxx-next-jeecgBoot-vue3\node_modules\.pnpm\@vitejs+plugin-vue-jsx@https+++registry.npmmirror.com+@vitejs+plugin-vue-jsx+-+plugin-vue-jsx_wpfjsfrcyfhppiaqhs2qki2ffu\node_modules\@babel\plugin-transform-typescript\package.json' imported from E:\work\VSCodeProjectWork\jeecg\xxxxxxxxx-next\xxxxxxxxx-next-jeecgBoot-vue3\node_modules\.pnpm\@vitejs+plugin-vue-jsx@https+++registry.npmmirror.com+@vitejs+plugin-vue-jsx+-+plugin-vue-jsx_wpfjsfrcyfhppiaqhs2qki2ffu\node_modules\@vitejs\plugin-vue-jsx\dist\index.cjs
Did you mean to import @babel+plugin-transform-typescript@https+++registry.npmmirror.com+@babel+plugin-transform-typ_t6dvr774uyzoiatluosu5niumu/node_modules/@babel/plugin-transform-typescript/lib/index.js?Plugin: vite:vue-jsxFile: E:/work/VSCodeProjectWork/jeecg/xxxxxxxxx-next/xxxxxxxxx-next-jeecgBoot-vue3/src/utils/factory/createAsyncComponent.tsxat legacyMainResolve (node:internal/modules/esm/resolve:214:26)at packageResolve (node:internal/modules/esm/resolve:840:14)at moduleResolve (node:internal/modules/esm/resolve:910:20)at defaultResolve (node:internal/modules/esm/resolve:1130:11)at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:396:12)at ModuleLoader.resolve (node:internal/modules/esm/loader:365:25)at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:240:38)at ModuleLoader.import (node:internal/modules/esm/loader:328:34)at importModuleDynamically (node:internal/modules/cjs/loader:1261:33)at importModuleDynamicallyWrapper (node:internal/vm/module:430:21)at importModuleDynamicallyCallback (node:internal/modules/esm/utils:186:14)at TransformContext.transform (E:\work\VSCodeProjectWork\jeecg\xxxxxxxxx-next\xxxxxxxxx-next-jeecgBoot-vue3\node_modules\.pnpm\@vitejs+plugin-vue-jsx@https+++registry.npmmirror.com+@vitejs+plugin-vue-jsx+-+plugin-vue-jsx_wpfjsfrcyfhppiaqhs2qki2ffu\node_modules\@vitejs\plugin-vue-jsx\dist\index.cjs:84:13)at Object.transform (file:///E:/work/VSCodeProjectWork/jeecg/xxxxxxxxx-next/xxxxxxxxx-next-jeecgBoot-vue3/node_modules/.pnpm/vite@5.2.13_@types+node@20.14.2_less@4.2.0/node_modules/vite/dist/node/chunks/dep-DEPSZ3SS.js:52318:62)at async loadAndTransform (file:///E:/work/VSCodeProjectWork/jeecg/xxxxxxxxx-next/xxxxxxxxx-next-jeecgBoot-vue3/node_modules/.pnpm/vite@5.2.13_@types+node@20.14.2_less@4.2.0/node_modules/vite/dist/node/chunks/dep-DEPSZ3SS.js:55073:29)at async viteTransformMiddleware (file:///E:/work/VSCodeProjectWork/jeecg/xxxxxxxxx-next/xxxxxxxxx-next-jeecgBoot-vue3/node_modules/.pnpm/vite@5.2.13_@types+node@20.14.2_less@4.2.0/node_modules/vite/dist/node/chunks/dep-DEPSZ3SS.js:64920:32)

同样的代码再同事电脑里就可以正常运行,
找到了个文章,解决方案是换个文件夹,原因的特殊字符,
jenkins目录下的vue3项目——pnpm install后运行报错——奇葩问题解决

我尝试了一下,将_改为了-,不好使,
E:\work\VSCodeProjectWork\jeecg\xxxxxxxxx_next\xxxxxxxxx-next-jeecgBoot-vue3
同级换个文件夹,不好使
E:\work\VSCodeProjectWork\jeecg\xxxxxxxxx_next\xxxxxxxxx-next-vue3
放在根目录下的A文件夹里,,好使,,
E:\A
按照原文件夹的名字拼接在一起变成了个巨长的文件夹名,不好使
E:\workVSCodeProjectWorkjeecgxxxxxxxxx_nextxxxxxxxxx-next-jeecgBoot-vue3
更改稍短点的路径,好使
E:\work\VSCodeProjectWork\jeecg\xxxxxxxxx_next\vue3

由此得出的pnpm不能在特别长的文件夹下使用

它的机制产生巨长的路径E:\work\VSCodeProjectWork\jeecg\xxxxxxxxx-next\xxxxxxxxx-next-jeecgBoot-vue3\node_modules\.pnpm\@vitejs+plugin-vue-jsx@https+++registry.npmmirror.com+@vitejs+plugin-vue-jsx+-+plugin-vue-jsx_wpfjsfrcyfhppiaqhs2qki2ffu\node_modules\@babel\plugin-transform-typescript\package.json' imported from E:\work\VSCodeProjectWork\jeecg\xxxxxxxxx-next\xxxxxxxxx-next-jeecgBoot-vue3\node_modules\.pnpm\@vitejs+plugin-vue-jsx@https+++registry.npmmirror.com+@vitejs+plugin-vue-jsx+-+plugin-vue-jsx_wpfjsfrcyfhppiaqhs2qki2ffu\node_modules\@vitejs\plugin-vue-jsx\dist\index.cjs实测已经561个字符了,与好使的路径只差26个字符,猜测是要控制在512以内,去除\ 536,536-26=510,也许就是答案吧,,

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com