Failed to resolve module specifier "react/jsx-runtime" since v2.0.0

See original GitHub issue

🐛 bug report

Sadly bundling the renderer index.html file of my app leads to another error, when opening the bundled app. IMPORTANT: this is no error during bundling. Background: my renderer is using react (nothing special):

And i get the error:

index.html:1 Uncaught TypeError: Failed to resolve module specifier "react/jsx-runtime". Relative references must start with either "/", "./", or "../".

🎛 Configuration (.babelrc, package.json, cli command)

My “dev” command to build the renderer:

parcel watch src/launcher/renderer/index.html --target electron-renderer --port 1236 --no-cache

My build command:

parcel build ./src/launcher/renderer/index.html --target electron-renderer --no-cache
{
  "electron-renderer": "./dist/launcher/index.html",
  "targets": {
    "electron-renderer": {
      "context": "electron-renderer",
      "distDir": "./dist/launcher/renderer",
      "isLibrary": false,
      "publicUrl": "."
    }
  }
}

🤔 Expected Behavior

if its work in watch mode - it should work in production mode.

😯 Current Behavior

It works in watch-mode, but after building the error occurs when starting the app.

💁 Possible Solution

Seems like node_modules are not corrce bundled bundled during production build or maybe it is the scope hoisting.

🔦 Context

Just want to build my electron app with a renderer using react.

💻 Code Sample

SourceCode:

<html>
  <head>
    <meta charset="UTF-8" />
    <title>My App</title>
  </head>
  <body>
    <!-- You can also require other files to run in this process -->
    <script type="module" src="./index.tsx"></script>
  </body>
</html>

🌍 Your Environment

Software Version(s)
Parcel 2.2.1 (tested with 2.0.0 and 2.1.1, as well)
Node 16.10.0
npm/Yarn 7.24.2
Operating System Ubuntu 20.04

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
KillerCodeMonkeycommented, Feb 12, 2022

For everyone having this issue: it seems parcel 2.x does not handle nodeIntegration settings for electron-renderer bundles.

I deactivated nodeIntegration and activated contextIsolation for my BrowserWindows created by the main process.

I added a contextBridge in the preload script that i build as “electron-main” context. My renderer will be now built as “browser” context and not as “electron-renderer”.

I leave this issue open, because as a bundler building everything “out-of-the-box” with electron support should really provide an out of the box solution for that.

Keep up with the nice work! Thx

0reactions
lemonspbcommented, Jun 29, 2022

i also faced this problem

Read more comments on GitHub >

github_iconTop Results From Across the Web

unable to resolve module react/jsx-runtime - Stack Overflow
React 17 introduce a new feature New JSX Transform . In short, JSX Transform can make you write react without import React from...
Read more >
Module not found: Can't resolve 'react/jsx-runtime' | bobbyhadz
To solve the error Module not found: Error: Can't resolve 'react/jsx-runtime', make sure to update the `react` package by opening your terminal in...
Read more >
failed to resolve module specifier "axios". relative references ...
I get Uncaught TypeError: Failed to resolve module specifier "axios". Relative references must start with either "/", "./", or ". Favicon for you.com...
Read more >
Trying to switch to ES from AMD - Uncaught TypeError
It seems that certain imports cause the following error to occur: "Uncaught TypeError: Failed to resolve module specifier "@esri/arcgis-html- ...
Read more >
TSConfig Option: jsxImportSource - TypeScript
Declares the module specifier to be used for importing the jsx and jsxs ... import React from "react"; ... The emitted JavaScript from...
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