Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Bug: Module not found: Error: Can't resolve 'react/jsx-runtime' #96

Open
3 tasks done
lauterry opened this issue Nov 25, 2024 · 2 comments
Open
3 tasks done

Comments

@lauterry
Copy link

lauterry commented Nov 25, 2024

Bug Report Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have pulled the latest main branch of the repository.
  • I have searched for related issues and found none that matched my issue.

Expected

I expect my project to build without error

Actual

When I build my project, I have the following error :

ERROR in ./node_modules/@marsidev/react-turnstile/dist/index.js 2:170-211
**Module not found: Error: Can't resolve 'react/jsx-runtime'** in '/Users/thierrylau/workspace/front/node_modules/@marsidev/react-turnstile/dist'
Did you mean 'jsx-runtime.js'?
BREAKING CHANGE: The request 'react/jsx-runtime' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.

My project use react 16 so I update react version to 17 for the error persist.

Here are some of my package.json dependencies :

"@babel/plugin-proposal-class-properties": "^7.17.12",
    "@babel/plugin-proposal-private-methods": "^7.17.12",
    "@babel/plugin-proposal-private-property-in-object": "^7.17.12",
    "@babel/preset-env": "^7.18.2",
    "@babel/preset-react": "^7.17.12",
    "@babel/register": "^7.17.7",
     "react": "^17.0.2",
     "react-dom": "^17.0.2",

Here is the content of my babel.sonfig.js

function isWebTarget(caller) {
	return Boolean(caller && caller.target === "web");
}

module.exports = api => {
	api.cache(() => process.env.NODE_ENV);

	// Jest will set process.env.NODE_ENV to 'test' if it's not set to something else.
	// You can use that in your configuration to conditionally setup only the compilation needed for
	// Jest
	const isTest = api.env("test");

	const isWeb = api.caller(isWebTarget);

	const presets = [
		[
			"@babel/preset-env",
			{
				corejs: 3,
				useBuiltIns: "usage",
				loose: true,
			},
		],
		[
			"@babel/preset-react",
			{
				runtime: "automatic",
				loose: true,
			},
		],
	];

	const plugins = [
		["@loadable/babel-plugin"],
		["@babel/plugin-proposal-private-methods", { loose: true }],
		["@babel/plugin-proposal-private-property-in-object", { loose: true }],
		["@babel/plugin-proposal-class-properties", { loose: true }],
	];

	if (isTest || !isWeb) {
		plugins.push(["dynamic-import-node", { noInterop: true }]);
	}

	if (process.env.INSTRUMENT) {
		plugins.push([
			"istanbul",
			{
				useInlineSourceMaps: false,
			},
		]);
	}

	return {
		presets,
		plugins,
	};
};

Best regards

Package Version

1.1.0

Browsers

Chrome

Additional Info

node version is v20.12.0

@lauterry lauterry changed the title 🐛 Bug: <short description of the bug> 🐛 Bug: Module not found: Error: Can't resolve 'react/jsx-runtime' Nov 25, 2024
@marsidev
Copy link
Owner

marsidev commented Dec 14, 2024

Sorry, are you still facing this? Have you tried deleting node_modules and npm i again?

These articles may help too:

@TheKidCoder
Copy link

Also hit this issue - Had to add this package to my list of nextTranspileModules = require('next-transpile-modules'); to fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants