Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vitpress构建报错 #18

Open
jijijiwinner opened this issue Feb 21, 2024 · 0 comments
Open

vitpress构建报错 #18

jijijiwinner opened this issue Feb 21, 2024 · 0 comments

Comments

@jijijiwinner
Copy link

jijijiwinner commented Feb 21, 2024

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",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant