Open chaklasiyanikunj opened 1 year ago
Node v14 not support syntax import * from 'node:assert'
, only import * from 'assert'
without node:
prefix
Try upgrade the version to v16?
Thank you for your reply. I already tried with Node versions: 16.17.0 and 16.17.1. But received the same error. I wrote only the above code. Do we need to require any other statement?
whats the version of electron?
I used the below electron version :
"electron": "^11.3.0",
"electron-local-crash-reporter": "^1.0.2",
"electron-progressbar": "^2.0.0",
"electron-updater": "^4.3.9",
The version of nodejs may under v14 some where. You can try a simple file:
const assert = requrire('node:assert')
console.log(assert)
or
import * as assert from 'node:assert'
console.log(assert)
v14 also suppports https://nodejs.org/api/esm.html#node-imports
I tried both statements. Still, I am getting this error. Do we need to add this npm package to Electron App?
I think https://www.npmjs.com/package/assert is unnecessary, it's not nodejs inernal module ( import by prfix node:
) .
provide a simple repo for debug ?
Sample Repo is available here and I added a Readme.txt file for more details. Electron_Sample_App.zip
electron v11 bundled with nodejs v12 : https://www.electronjs.org/blog/electron-11-0 electron v12 bundled with nodejs v14, pls try
I found that you need to add this to your BrowserWindow:
webPreferences: {
sandbox: false,
//nodeIntegration: true, // Or this
}
Otherwise node libraries wont be available. Note that this is done for security reasons.
Tangential note (unrelated to the above issue) electronV21+ wont work due to https://www.electronjs.org/blog/v8-memory-cage
I installed win32-API version => "win32-api": "^20.1.0". My Node version is 14.18.5.
The Notepad file is open on my PC.
When trying this code in electron it gives this => "Cannot find module 'node: assert' Require stack" error.
I've tried to find the solution. but haven't found anything yet. Anyone any idea about this?