Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

fix(kit): log module id to the console when import fails #8198

Merged
merged 4 commits into from
Oct 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/kit/src/module/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ async function normalizeModule (nuxtModule: string | NuxtModule, inlineOptions?:
const _src = resolveModule(resolveAlias(nuxtModule), { paths: nuxt.options.modulesDir })
// TODO: also check with type: 'module' in closest `package.json`
const isESM = _src.endsWith('.mjs')
nuxtModule = isESM ? await importModule(_src) : requireModule(_src)

try {
nuxtModule = isESM ? await importModule(_src) : requireModule(_src)
} catch (error: unknown) {
console.error(`Error while requiring module \`${nuxtModule}\`: ${error}`)
throw error
}
}

// Throw error if input is not a function
Expand Down