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.

The requested module 'react-is/index.js' does not provide an export named 'ForwardRef'

See original GitHub issue

Recent minor release breaks storybook for react compilation. I think the issue exists in 14.3.3 and 14.3.4 versions and my workaround was to add the following to package.josn:

"resolutions": {
    "**/react-element-to-jsx-string": "14.3.2"
 }

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:4
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Andaristcommented, Oct 25, 2021

This happens because Vite serves react-is “as-is” - without transforming it anyhow and Vite relies on native modules in the browser. The “imported” file is this:

'use strict';

if ("development" === 'production') {
  module.exports = require('./cjs/react-is.production.min.js');
} else {
  module.exports = require('./cjs/react-is.development.js');
}

and as we can see this is just a CJS file.

According to the Vite docs this should be transformed during a “pre-bundle” step: https://vitejs.dev/guide/features.html#npm-dependency-resolving-and-pre-bundling

From my PoV, it looks like an issue with Vite - I’m not familiar with it enough to say what’s exactly broken. The react-is is using the very same “structure” of distributed files etc as React itself so this should just be handled in the same way - and I’m unsure why it isn’t in this case. Could you report this to the Vite team? Maybe they would have some pointers regarding this problem.

0reactions
teyccommented, Oct 29, 2022

I’m new to Vite, so I’m not sure how this works, but it seems the following helps:

// vite.config.ts
import * as reactPlugin from 'vite-plugin-react'
import type { UserConfig } from 'vite'

const config: UserConfig = {
  jsx: 'react',
  optimizeDeps: {
    include: [
     'react-is',
    ]
  },
  plugins: [reactPlugin]
}

export default config

and if you have a look at node_modules/.vite_opt_cache/react-is.js it looks like it creates an ESM

reactIs = { isAsyncMode: ..., isSuspense: ... }
:
:
export { reactIs as default }
Read more comments on GitHub >

github_iconTop Results From Across the Web

The requested module does not provide an export named ...
This error is referring to node_modules/emotion-theming/dist/emotion-theming.browser.esm.js?v=236b7c74 file. Oh, and btw, @emotion/react is also ...
Read more >
The requested module '' does not provide an export named ...
When I try adding my own export in TableCsv.js it says A module cannot have multiple default exports.ts(2528). Here is my code. main.js...
Read more >
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 >
module 'react' does not provide an export named 'useRef'
Has anyone run into similar issues and know what you can do to resolve these issues? next.config // next.config.js const withTM = require('next-transpile- ......
Read more >
the requested module 'fs' does not provide an export named 'fs ...
js. (Browsers don't have a native fs module.) Use it in your backend node.js application, not the frontend. Since ...
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