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

import naive from 'naive-ui' build error: export { default, install } from './preset'; ^^^^^^ SyntaxError: Unexpected token 'export' #1399

Closed
3 tasks done
haohao809 opened this issue Sep 26, 2022 · 1 comment
Labels
bug: pending triage Maybe a bug, waiting for confirmation

Comments

@haohao809
Copy link

Describe the bug

update "vitepress": "^1.0.0-alpha.6"
in theme index.js
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)

Reproduction

npm run docs:build

Expected behavior

theme Full Import naive-ui
build success

System Info

"vitepress": "^1.0.0-alpha.6"
  node : 14.16.2
  browsers : chrome
 system windows

Additional context

No response

Validations

  • Follow our Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
@haohao809 haohao809 added the bug: pending triage Maybe a bug, waiting for confirmation label Sep 26, 2022
@brc-dd
Copy link
Member

brc-dd commented Sep 26, 2022

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug: pending triage Maybe a bug, waiting for confirmation
Projects
None yet
Development

No branches or pull requests

2 participants