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

Full import naive-ui in vitepress build Error #3786

Closed
haohao809 opened this issue Sep 27, 2022 · 4 comments
Closed

Full import naive-ui in vitepress build Error #3786

haohao809 opened this issue Sep 27, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@haohao809
Copy link

TuSimple/naive-ui version (版本)

2.33.3

Vue version (Vue 版本)

3.2.39

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

Chrome(105.0.5195.102)

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

windows(Windows 10 19044.1645)

Node version (Node 版本)

16.14.2

Reappearance link (重现链接)

https://github.com/haohao809/vitepress-test.git

Reappearance steps (重现步骤)

vitepress (version 1.0.0-alpha.6)

import naive from 'naive-ui'
enhanceApp({ app }) {
app.use(naive)
}

npm run docs:build

✓ building client server bundles...
(node:31512) 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)
build error:
C:\Users\A0\Documents\vitePress\node_modules\naive-ui\es\index.js:1
export { default, install } from './preset';
^^^^^^

SyntaxError: Unexpected token 'export'
at wrapSafe (node:internal/modules/cjs/loader:1032:15)
at Module._compile (node:internal/modules/cjs/loader:1067:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at ModuleWrap. (node:internal/modules/esm/translators:168:29)
at ModuleJob.run (node:internal/modules/esm/module_job:197:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:337:24)

Expected results (期望的结果)

build Success

Actual results (实际的结果)

build Error

Remarks (补充说明)

I created an issuse on 'vitepress' ,but the developer answered...
Consider creating an issue on naive-ui's repo instead. Their ESM is completely invalid. First,
the files must be of extension .mjs as they have not set type module in their package.json.
Second, each import must have extension specified.

@github-actions github-actions bot added the untriaged need to sort label Sep 27, 2022
@codenfree
Copy link

i got similar issue. i checked older versions. v2.32.1 is working fine but not newer versions.

@07akioni
Copy link
Collaborator

07akioni commented Oct 3, 2022

I think this is caused by import map. It point import statament to es entry however nodejs runtime doesn't recogonize it since it's not a package with module=true or a file mjs extensition.

@07akioni 07akioni added bug Something isn't working and removed untriaged need to sort labels Oct 3, 2022
@sky124380729
Copy link

vuejs/vitepress#1399
我在2.34.2版本遇到了相同的问题
image
请问现在修复了吗

@07akioni
Copy link
Collaborator

07akioni commented May 6, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants