Quantcast
Channel: Active questions tagged require - Stack Overflow
Viewing all articles
Browse latest Browse all 143

Uncaught Error: Dynamic require of "child_process" is not supported

$
0
0

I am trying to create a 'container' application that either downloads other apps if they don't exist or opens their .exe files if they do exist when the user clicks on their button in the 'container' app. Initially, I tried executing an msedge.exe file with a .bat file, which worked successfully.

Our team is using Electron/React/Node.js/Vite, and we have set up a boilerplate as a launchpad. I created a 'Deeplinker.jsx' script and I am rendering it through 'main.tsx'. The program runs fine and displays my alert message, however, it errors out when I uncomment the following two lines of code:

import {execFile} from 'child_process';execFile("C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe");

Here's the error message:

Uncaught Error: Dynamic require of "child_process" is not supportedat chunk-7FP5O474.js?v=d7119b79:7:9at child_process.mjs:1:50

I have isolated the error to these two commented lines in my 'Deeplinker.jsx' file. It is possible that our network manager has locked down our permissions, so maybe that's why I am getting an error.

Can someone please provide suggestions and help me resolve this issue? Here are the scripts:

// main.tsximport React from 'react'import ReactDOM from 'react-dom/client'import App from './App.tsx'import DeepButton from './Deeplinker.jsx'import './index.css'ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(<React.StrictMode><DeepButton/></React.StrictMode>,)postMessage({ payload: 'removeLoading' }, '*')
// Deeplinker.jsximport {execFile} from 'child_process';function DeepLink(){    alert("Button pressed");    execFile("C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe");}function DeepButton(){    return (<h1><button  onClick={DeepLink}>Deeplink</button></h1>);}export default DeepButton;

Viewing all articles
Browse latest Browse all 143

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>