Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Namespace 'NodeJS' has no exported member 'Require'

I'm new in Electron.. and i just following this guide: https://www.geeksforgeeks.org/integrate-angular-7-with-electronjs/?ref=rp

but, i don't know why, i can't continue the step 4, on accessing the electron, and keep popping this when doing build or even just serve.

Error: node_modules/electron/electron.d.ts:6594:21 - error TS2694: Namespace 'NodeJS' has no exported member 'Require'.

6594 require: NodeJS.Require; ~~~~~~~

npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] electron: ng build --prod && electron . npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] electron script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

i hope anyone here, understand with this and able to solve this. thank you! because my goal is to connect ipcMain, using ipcRenderer that i triggered on Angular Services.

like image 715
Betavian Benedictus Avatar asked Mar 07 '21 14:03

Betavian Benedictus


1 Answers

I believe this problem happened because of an old version of @types/node, as Angular uses TypeScript as its backbone.

npm update itself wouldn't work if the update is a breaking change.

In order to fix this, update your package.json to use the latest version of @types/node, at this time of writing 14.14.33. You can update it manually by editing that file.

After updating your @types/node, run npm install again, then serve it, and it should work.

If it still fails, update your Angular CLI to the latest version by using npm uninstall -g @angular/cli, then npm install -g @angular/cli. You might be using an outdated Angular CLI.

like image 79
Nicholas Avatar answered Oct 17 '22 09:10

Nicholas