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

ES import error when building vue component #759

Closed
King-of-Infinite-Space opened this issue Nov 11, 2022 · 3 comments
Closed

ES import error when building vue component #759

King-of-Infinite-Space opened this issue Nov 11, 2022 · 3 comments

Comments

@King-of-Infinite-Space
Copy link

I'm using VitePress to build pages that contain @giscus/vue component. It works fine on dev server, but when building the following error occurs. The error goes away if the filename index.es.js is changed to index.mjs. (Similar error is reported here: vuejs/vitepress#1399)

(node:9201) 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:
 /home/xxx/repo/node_modules/.pnpm/@[email protected][email protected]/node_modules/@giscus/vue/dist/index.es.js:1
import { defineComponent as n, ref as l, onMounted as a, openBlock as i, createElementBlock as o, createCommentVNode as u } from "vue";
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at Object.compileFunction (node:vm:360:18)
    at wrapSafe (node:internal/modules/cjs/loader:1055:15)
    at Module._compile (node:internal/modules/cjs/loader:1090:27)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:170:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:533:24)
 ELIFECYCLE  Command failed with exit code 1.
@King-of-Infinite-Space
Copy link
Author

Just noticed that PR #573 is fixing this issue

@laymonage
Copy link
Member

Please try updating to v2.2.3 and check if the issue is fixed.

@King-of-Infinite-Space
Copy link
Author

thanks, the issue has been fixed in the new version

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

2 participants