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.

bug: useVuelidate detected as a commonJS module

See original GitHub issue

Describe the bug When running a build (node .output/server/index.mjs) with nuxt 3 on an app that uses Vuelidate, I get an error that Vuelidate is a common JS module :

Named export 'useVuelidate' not found. The requested module '@vuelidate/core' 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:

I’m no JS expert, but vuelidate looks very much like an ESM module, no idea why it would be detected wrongly. The app runs fine in dev mode.

Reproduction URL

Not a JS fiddle, but the repo is open-source, I hope that’s OK.

To Reproduce Steps to reproduce the behavior:

  1. nuxi build
  2. node .output/server/index.mjs
  3. get the error

Expected behavior Homepage is shown

Additional context

Listening on http://localhost:3000/
Named export 'useVuelidate' not found. The requested module '@vuelidate/core' 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 '@vuelidate/core';
const { useVuelidate } = pkg;

  at ModuleJob._instantiate (node:internal/modules/esm/module_job:128:21)  
  at async ModuleJob.run (node:internal/modules/esm/module_job:194:5)  
  at async Promise.all (index 0)  
  at async ESMLoader.import (node:internal/modules/esm/loader:409:24)  
  at async file://./.output/server/chunks/app/render.mjs:527:24  
  at async renderMiddleware (file://./.output/server/chunks/app/render.mjs:576:20)  
  at async handle (file://./.output/server/node_modules/h3/dist/index.mjs:601:19)

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
dobromir-hristovcommented, Sep 25, 2022

Oh well then setting type: module wont do… I will research for a better bundler so that we can have proper .mjs files.

I cannot add type: module because not all exports we have are modules…

1reaction
dobromir-hristovcommented, Sep 25, 2022

mmm OK that may be me… let me change that…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Named export 'Types' not found. The requested module ...
Solution #2. Switch to commonjs , I can keep the import/export syntax in my graphql module and compile it as a cjs module....
Read more >
monterail - Bountysource
Describe the bug. Is there a way to use vuelidate with PrimeVue DataTable? ... that uses Vuelidate, I get an error that Vuelidate...
Read more >
Node Modules at War: Why CommonJS and ES ... - Code Red
In the first phase, it parses the script to detect calls to import and export without running the imported script. In the parsing...
Read more >
Guide | Vuelidate
A simple, but powerful, lightweight model-based validation for Vue.js 3 and 2.
Read more >
cannot set properties of undefined (setting '$router') - You.com
It can be seen that vue-gapi.common.js contains Vue 3 code, ... I'm planning to use vuelidate and vuelidate-Error-Extractor. so I have installed these ......
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