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

NPM run build issue with Vueperslides #4618

Closed
1 task
midlantica opened this issue Sep 4, 2022 · 5 comments · Fixed by #4639
Closed
1 task

NPM run build issue with Vueperslides #4618

midlantica opened this issue Sep 4, 2022 · 5 comments · Fixed by #4639
Assignees
Labels
- P3: minor bug An edge case that only affects very specific usage (priority)

Comments

@midlantica
Copy link

What version of astro are you using?

latest

Are you using an SSR adapter? If so, which one?

no

What package manager are you using?

npm

What operating system are you using?

Mac OS Big Sur 11.6.8

Describe the Bug

`> npm run build

@example/basics@0.0.1 build
astro build

11:44:45 PM [build] output target: static
11:44:45 PM [build] Collecting build info...
11:44:45 PM [build] Completed in 577ms.
11:44:45 PM [build] Building static entrypoints...
11:44:48 PM [build] Completed in 3.00s.

building client
Completed in 1.02s.

generating static routes
error Named export 'VueperSlide' not found. The requested module 'vueperslides' 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 'vueperslides';
const { VueperSlides, VueperSlide } = pkg;

**/dist/entry.mjs?time=1662266689397:4
/
empty css */import { VueperSlides, VueperSlide } from 'vueperslides';
^^^^^^^^^^^
SyntaxError: Named export 'VueperSlide' not found. The requested module 'vueperslides' 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 'vueperslides';
const { VueperSlides, VueperSlide } = pkg;

Link to Minimal Reproducible Example

https://github.com/midlantica/rogerivens.com

Participation

  • I am willing to submit a pull request for this issue.
@midlantica
Copy link
Author

midlantica commented Sep 4, 2022

Love Astro. I'm excited to do new work! I'm a bit of a junior.. maybe it's something simple, maybe it's a real issue? Just trying to finish a little job... but cannot build! All is well in npm run dev. Thanks.

@matthewp
Copy link
Contributor

matthewp commented Sep 6, 2022

Does this work:

import * as pkg from 'vueperslides';
const { VueperSlides, VueperSlide } = pkg;

@matthewp
Copy link
Contributor

matthewp commented Sep 6, 2022

Setting noExternal on this package fixes it. Unfortunately not every package is compatible with Node ESM is this is one of them:

export default defineConfig({
  vite: {
    ssr: {
      noExternal: ['vueperslides']
    }
  }
});

https://stackblitz.com/github/withastro/astro/tree/latest/examples/minimal?file=src%2Fpages%2Findex.astro&on=stackblitz

This one has pretty high download numbers so I'm going to make it so we do this for you.

@matthewp matthewp added the - P3: minor bug An edge case that only affects very specific usage (priority) label Sep 6, 2022
@matthewp matthewp self-assigned this Sep 6, 2022
@matthewp
Copy link
Contributor

matthewp commented Sep 6, 2022

Fixed in #4639

@matthewp matthewp closed this as completed Sep 6, 2022
@midlantica
Copy link
Author

Thank you so much for your help! I got insane busy and couldn't try fix, or thank you earlier.

It works now! Astro rocks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P3: minor bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants