ATQQ / uni-vue3-ts-template

开箱即用的uni-app vue3 TS 工程化模板项目,支持小程序/H5/APP开发使用,包含pinia,sass/less,axios,vitest,eslint,Unocss
https://uni.vue3.sugarat.top
MIT License
256 stars 68 forks source link

pnpm run dev:h5:ssr 报错 #22

Open 350469960 opened 1 year ago

350469960 commented 1 year ago

一、错误信息如下:

/Users/xunwu/docod/test/uni-vue3-ts-template/node_modules/.pnpm/vk-uview-ui@1.3.7/node_modules/vk-uview-ui/index.js:2 import mixin from './libs/mixin/mixin.js' ^^^^^^

SyntaxError: Cannot use import statement outside a module at wrapSafe (internal/modules/cjs/loader.js:1001:16) at Module._compile (internal/modules/cjs/loader.js:1049:27) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10) at Module.load (internal/modules/cjs/loader.js:950:32) at Function.Module._load (internal/modules/cjs/loader.js:790:12) at ModuleWrap. (internal/modules/esm/translators.js:199:29) at ModuleJob.run (internal/modules/esm/module_job.js:183:25) at async Loader.import (internal/modules/esm/loader.js:178:24) at async nodeImport (file:///Users/xunwu/docod/test/uni-vue3-ts-template/node_modules/.pnpm/vite@3.2.3_ppdxls77r7tfsxvxidunrbldv4/node_modules/vite/dist/node/chunks/dep-51c4f80a.js:53132:21) at async eval (/src/main.ts:9:31) at async instantiateModule (file:///Users/xunwu/docod/test/uni-vue3-ts-template/node_modules/.pnpm/vite@3.2.3_ppdxls77r7tfsxvxidunrbldv4/node_modules/vite/dist/node/chunks/dep-51c4f80a.js:53053:9)

二、如果package.js加入"type":"module",则报如下错误:

failed to load config from /Users/xunwu/docod/test/uni-vue3-ts-template/vite.config.ts

error when starting dev server: TypeError: uni is not a function at file:///Users/xunwu/docod/test/uni-vue3-ts-template/vite.config.ts.timestamp-1680072557068.mjs:9:5 at ModuleJob.run (internal/modules/esm/module_job.js:183:25) at async Loader.import (internal/modules/esm/loader.js:178:24) at async loadConfigFromBundledFile (file:///Users/xunwu/docod/test/uni-vue3-ts-template/node_modules/.pnpm/vite@3.2.3_ppdxls77r7tfsxvxidunrbldv4/node_modules/vite/dist/node/chunks/dep-51c4f80a.js:62827:21) at async loadConfigFromFile (file:///Users/xunwu/docod/test/uni-vue3-ts-template/node_modules/.pnpm/vite@3.2.3_ppdxls77r7tfsxvxidunrbldv4/node_modules/vite/dist/node/chunks/dep-51c4f80a.js:62712:28) at async resolveConfig (file:///Users/xunwu/docod/test/uni-vue3-ts-template/node_modules/.pnpm/vite@3.2.3_ppdxls77r7tfsxvxidunrbldv4/node_modules/vite/dist/node/chunks/dep-51c4f80a.js:62336:28) at async Module.createServer (file:///Users/xunwu/docod/test/uni-vue3-ts-template/node_modules/.pnpm/vite@3.2.3_ppdxls77r7tfsxvxidunrbldv4/node_modules/vite/dist/node/chunks/dep-51c4f80a.js:61636:20) at async createSSRServer (/Users/xunwu/docod/test/uni-vue3-ts-template/node_modules/.pnpm/@dcloudio+vite-plugin-uni@3.0.0-alpha-3060920221114001_vite@3.2.3+vue@3.2.45/node_modules/@dcloudio/vite-plugin-uni/dist/cli/server.js:42:18) at async CAC.runDev (/Users/xunwu/docod/test/uni-vue3-ts-template/node_modules/.pnpm/@dcloudio+vite-plugin-uni@3.0.0-alpha-3060920221114001_vite@3.2.3+vue@3.2.45/node_modules/@dcloudio/vite-plugin-uni/dist/cli/action.js:22:28)  ELIFECYCLE  Command failed with exit code 1.      三、本地环境  node: v14.19.3  pnpm: 7.26.3    

ATQQ commented 1 year ago

get 晚点看一下。。。

应该是这个vk-uview-ui 包有些问题 ,如果不用这个组件库的话可以先将相关代码移除

ATQQ commented 1 year ago

解法肯定不是 加 type:"module"

350469960 commented 1 year ago

好的,以前其他人提的换成tumi 组件库的有集成好吗?

ATQQ commented 1 year ago

这个没有,如需要可以先自行按照相关文档接入 uni组件库这块不太好找个大而全 接入简单,又多端兼容的 😄

ATQQ commented 1 year ago

最近才有空看这个问题 ,目测应该是 这个组件库不支持SSR 具体我再抽时间看一下 找个可替代的,我先在文档里移除一下SSR