Skip to content

vitpress构建报错 #18

@jijijiwinner

Description

@jijijiwinner

vitpress构建组件文档时报错(package.json文件中添加了"type": "module",):
import { ArrowDown, Search, ArrowRight } from "@nutui/icons-vue";
^^^^^^^^^
SyntaxError: Named export 'ArrowDown' not found. The requested module '@nutui/icons-vue' 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 '@nutui/icons-vue';
const { ArrowDown, Search, ArrowRight } = pkg;

根据报错修改删除package.json文件中的"type": "module",
代码改成:import * as pkg from "@nutui/icons-vue"
const { ArrowDown } = pkg后编译报错:
(node:33253) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use node --trace-warnings ... to show where the warning was created)
/Users/jijianmei/jjm/work/projects/za-template/za-component/zat-h5-components/node_modules/.pnpm/@nutui+icons-vue@0.1.1/node_modules/@nutui/icons-vue/dist/es/index.es.js:2
export { config as IconFontConfig } from "./icons/IconFontConfig.js";
^^^^^^
SyntaxError: Unexpected token 'export'

想问下这个nutui/icons-vue不是应该支持esmodule的方式么?应该如何修改?
PS:本地运行没有问题,版本号如下
"vite": "^4.5.0",
"vitepress": "1.0.0-rc.15",
"@nutui/icons-vue": "^0.1.1",

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions