bug: useVuelidate detected as a commonJS module
See original GitHub issueDescribe 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:
nuxi build
node .output/server/index.mjs
- 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:
- Created a year ago
- Reactions:1
- Comments:12 (5 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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…mmm OK that may be me… let me change that…