question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

npm run generate breaks when import contains re-export `export { default as xxx } from 'ooo'`

See original GitHub issue

   Forwarded from downstream issue:


Environment

Nuxt project info:


  • Operating System: Darwin
  • Node Version: v14.18.2
  • Nuxt Version: 3.0.0-rc.3
  • Package Manager: npm@6.14.17
  • Builder: vite
  • User Config: typescript, publicRuntimeConfig, buildModules, alias, vite
  • Runtime Modules: -
  • Build Modules: @pinia/nuxt@0.1.9

Reproduction

https://codesandbox.io/s/angry-johnson-3h59db?file=/app.vue

Run npm run generate from the terminal.

<template>
  <div>
    <NuxtWelcome />
  </div>
</template>
<script>
// the swiper js package has re-export in entry point
import { Pagination } from "swiper";
console.log(Pagination);

export default {};
</script>

Describe the bug

If package you used contains re-export syntex, then npm run generate didn’t work.

Additional context

The import was incorrectly resolved to import Pagination from './modules/pagination/pagination.js'; in the /sandbox/.nuxt/prerender/chunks/app/server.mjs . and thus break the build

Logs

ERROR  [nuxt] [request error] Cannot find module '/sandbox/.nuxt/prerender/chunks/app/modules/pagination/pagination.js' imported from /sandbox/.nuxt/prerender/chunks/app/server.mjs
  at new NodeError (internal/errors.js:322:7)
  at finalizeResolution (internal/modules/esm/resolve.js:308:11)
  at moduleResolve (internal/modules/esm/resolve.js:731:10)
  at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:842:11)
  at Loader.resolve (internal/modules/esm/loader.js:89:40)
  at Loader.getModuleJob (internal/modules/esm/loader.js:242:28)
  at ModuleWrap.<anonymous> (internal/modules/esm/module_job.js:76:40)
  at link (internal/modules/esm/module_job.js:75:36)

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
pi0commented, Sep 1, 2022

@danielroe I’m pretty sure linked PR is something worth to consider but I cannot reproduce issue anymore with nuxt edge. Can you please help to make a reproduction for nitro? (Update: Neither with rc.8 and latest deps. both prod and dev log [Function: Pagination]…)

1reaction
danielroecommented, Aug 5, 2022

Good point. Will do my best to replicate in simpler form. Might be soluble in nuxt also.

Read more comments on GitHub >

github_iconTop Results From Across the Web

npm run generate breaks when import contains re-export ` ...
npm run generate breaks when import contains re-export export { default as xxx } from 'ooo' #5348. Open. mmis1000 opened this issue on...
Read more >
npm start throwing errors related to the exports for no reason
On both my PC and old laptop (with windows) it works fine, but here i'm getting errors saying that export 'default' (imported as...
Read more >
Overview
Building on that work, the new Generator type is an Iterator that always has both the return and throw methods present, and is...
Read more >
error [authguard] in order to use "defaultstrategy", please, ...
When I run npm test on default procject I get [ExceptionHandler] In order to use "defaultStrategy", please, ensure to import PassportModule in each...
Read more >
Correctly auto-import default ES6 modules re-exported as ...
This is a problem with reactstrap components that has to be imported as import {XXX} from "reactstrap"; but are imported as import XXX...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found