antfu-collective / vite-ssg

Static site generation for Vue 3 on Vite
MIT License
1.32k stars 136 forks source link

SyntaxError: Cannot use import statement outside a module #402

Closed citrusjunoss closed 4 months ago

citrusjunoss commented 4 months ago

How do I find out which package is causing the error?

.vite-ssg-temp/0cd4q0k8bs/assets/index-468138bf.js:1 import { defineComponent, ref, resolveComponent, mergeProps, unref, withCtx, createVNode, TransitionGroup, openBlock, createBlock, createCommentVNode, renderSlot, useSSRContext, onMounted, onUnmounted, toDisplayString, Fragment, renderList, computed, reactive } from "vue"; import { ssrRenderAttrs, ssrRenderComponent, ssrRenderClass, ssrRenderSlot, ssrRenderList, ssrInterpolate, ssrRenderAttr } from "vue/server-renderer"; import { l as libExports } from "./index-10ef7e71.js"; import { P as PullRefresh } from "./index-3f83af24.js"; import { _ as _export_sfc, I as Icon, f as frontPagination } from "../main.mjs"; import { t as textConfigurationList, s as serviceList } from "./config-e399fb3c.js"; import { u as useImageUrl } from "./useImageUrl-06401fc9.js"; import QzdJs from "qzd-js"; import { browserEnv } from "@qzd-utils/core/lib/env.js"; import { useRouter } from "vue-router"; import { S as Swipe, a as SwipeItem } from "./index-e2d637d4.js"; import dayjs from "dayjs"; import { g as getQzdV1SpaceHomeGetLatestUnreadRecord, p as postQzdV1SpaceHomeUpdateReadStatus } from "./BossAppExpertHomeController-e5b3cfed.js"; import { P as Popover } from "./index-e912b7b9.js"; import { p as postQzdV1SpaceExpertRecommend } from "./BossAppExpertController-3af5fd8b.js"; import { o as openNewPage } from "./qzd-e9639af1.js"; import { K as KzExpertCard } from "./KzExpertCard-fa3282fc.js"; import { p as postAppFundAchievementRecommend } from "./AppFundAchievementController-8c47af2e.js"; import { A as AchCard } from "./AchCard-291ef674.js"; import "@vant/use"; import "@vue/shared"; import "@vant/popperjs"; import "pinia"; import "@yzfe/vue3-svgicon"; import "vite-ssg"; import "@qzd-utils/business/lib/fetch.js"; import "@qzd-utils/business/lib/utils/index.js"; import "@qzd-utils/business/lib/sm.js"; import "@qzd-utils/business/lib/shence.js"; import "@qzd-utils/business/lib/arms.js"; import "@qzd-utils/core/lib/tool.js"; import "./use-sync-prop-ref-567af492.js"; import "@qzd-utils/core/lib/debounce.js"; import "./index-26748a60.js"; import "./__vue-jsx-ssr-register-helper-590a98f1.js"; import "./TagDialog-549b48ca.js"; import "./close_msg-1e42429f.js"; import "@qzd-utils/core/lib/highlightText.js"; import "./usevDompurifyHtml-98fbceda.js"; import "vue-dompurify-html";

citrusjunoss commented 4 months ago

error message

bash (node:25803) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension. (Usenode --trace-warnings ...` to show where the warning was created) /Users/qzd/Documents/code/kzone-h5-cxy/.vite-ssg-temp/0cd4q0k8bs/assets/index-468138bf.js:1 import { defineComponent, ref, resolveComponent, mergeProps, unref, withCtx, createVNode, TransitionGroup, openBlock, createBlock, createCommentVNode, renderSlot, useSSRContext, onMounted, onUnmounted, toDisplayString, Fragment, renderList, computed, reactive } from "vue"; ^^^^^^

SyntaxError: Cannot use import statement outside a module at internalCompileFunction (node:internal/vm:73:18) at wrapSafe (node:internal/modules/cjs/loader:1176:20) at Module._compile (node:internal/modules/cjs/loader:1218:27) at Module._extensions..js (node:internal/modules/cjs/loader:1308:10) at Module.load (node:internal/modules/cjs/loader:1117:32) at Module._load (node:internal/modules/cjs/loader:958:12) at ModuleWrap. (node:internal/modules/esm/translators:169:29) at ModuleJob.run (node:internal/modules/esm/module_job:194:25)

[vite-ssg] An internal error occurred. [vite-ssg] Please report an issue, if none already exists: https://github.com/antfu/vite-ssg/issues /Users/qzd/Documents/code/kzone-h5-cxy/.vite-ssg-temp/0cd4q0k8bs/assets/index-468138bf.js:1 import { defineComponent, ref, resolveComponent, mergeProps, unref, withCtx, createVNode, TransitionGroup, openBlock, createBlock, createCommentVNode, renderSlot, useSSRContext, onMounted, onUnmounted, toDisplayString, Fragment, renderList, computed, reactive } from "vue"; ^^^^^^

SyntaxError: Cannot use import statement outside a module at internalCompileFunction (node:internal/vm:73:18) at wrapSafe (node:internal/modules/cjs/loader:1176:20) at Module._compile (node:internal/modules/cjs/loader:1218:27) at Module._extensions..js (node:internal/modules/cjs/loader:1308:10) at Module.load (node:internal/modules/cjs/loader:1117:32) at Module._load (node:internal/modules/cjs/loader:958:12) at ModuleWrap. (node:internal/modules/esm/translators:169:29) at ModuleJob.run (node:internal/modules/esm/module_job:194:25) `

citrusjunoss commented 4 months ago

node: v18.15.0 macos: 13.6.1 vite: 4.3.4 vite-ssg: 0.23.7

antfu commented 4 months ago

We temporarily closed this due to the lack of enough information. We could not identify whether it was a bug or a userland misconfiguration with the given info. Please provide a minimal reproduction to reopen the issue. Thanks.

Why reproduction is required