Skip to content

Build error when using vite-ssg/使用vite-ssg进行构建时出错 #4225

@censujiang

Description

@censujiang

TuSimple/naive-ui version (版本)

2.34.2

Vue version (Vue 版本)

3.2.45

Browser and its version (浏览器及其版本)

Chrome 108

System and its version (系统及其版本)

Windows 10

Node version (Node 版本)

16

Reappearance link (重现链接)

https://stackblitz.com/edit/github-2sappy

Reappearance steps (重现步骤)

Introduce any component that exists in navie-ui, and then execute npm run build
将任意navie-ui中的组件引入,然后执行npm run build

Expected results (期望的结果)

Able to build the site normally
能够正常构建站点

Actual results (实际的结果)

build error
构建出错

Remarks (补充说明)

[vite-ssg] An internal error occurred.
[vite-ssg] Please report an issue, if none already exists: https://github.com/antfu/vite-ssg/issues
file:///D:/git/xxx/xxx/.vite-ssg-temp/main.mjs:14
import { useMessage, NModal, NCard, NMessageProvider } from "naive-ui";
                             ^^^^^
SyntaxError: Named export 'NCard' not found. The requested module 'naive-ui' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'naive-ui';
const { useMessage, NModal, NCard, NMessageProvider } = pkg;

    at ModuleJob._instantiate (node:internal/modules/esm/module_job:123:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:189:5)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:533:24)
    at async build (file:///D:/git/xxx/xxx/node_modules/vite-ssg/dist/shared/vite-ssg.62550b28.mjs:996:87)
    at async Object.handler (file:///D:/git/xxx/xxx/node_modules/vite-ssg/dist/node/cli.mjs:29:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions