Requested module does not provide export named 'default'
See original GitHub issueEnvironment
- Node Version: v14.16.0
- Nuxt Version: 3.0.0
- Package Manager: npm@7.17.0
- Bundler: Vite
Reproduction
here you can see a very simple reproduction link https://stackblitz.com/edit/github-nl4dyg?file=app.vue
npm run dev
Describe the bug
I’m trying to use class-validator packages.
first I faced a problem mentioned here and solved it by adding this package to build.transpile
in nuxt.config.ts
file.
then this error starts to show up
SyntaxError: The requested module '/_nuxt/node_modules/validator/lib/isLatLong.js?v=cba03522' does not provide an export named 'default'
the validator package is one of class-validator dependencies.
the weird part is that the code runs perfectly on the server process
and the error only occurs on the browser and it works fine on both server and browser in production mode!
Additional context
No response
Logs
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (3 by maintainers)
Top Results From Across the Web
Requested module does not provide export named 'default'
To solve the error "The requested module does not provide an export named 'default'", use the default keyword when exporting a value from...
Read more >42 - Stack Overflow
Uncaught SyntaxError: The requested module './add.js' does not provide an export named 'add' ; <head> ; <script type="module" src="app.js"> ; </ ...
Read more >How to Solve does not provide an export named 'default'
To solve the error 'does not provide an export name default' in JavaScript, use the default keyword to make it the default export...
Read more >Misleading error that module does not provide export #32137
SyntaxError: The requested module './dependency.cjs' is a CommonJS module, which can only provide a default export, not named exports, to an ES ...
Read more >vite the requested module does not provide an export named ...
Dec 24, 2021 ... The reason it didn't work is that Vue provides a named export, whereas you are trying to import it...
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 FreeTop 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
Top GitHub Comments
This seems to be solved by disabling ‘optimizeDeps’ on this module:
I found a workaround for this issue by using Webpack instead of Vite.
you can enable Webpack by setting vite to false in nuxt.config.ts
but you should remove the
class-validator
package frombuild.transpile