Electron + Angular + node-pty missing file when compile
namdien177 opened this issue · 4 comments
Environment details
- OS: Windows 10
- OS version: 1903 (build 18362.239)
- node-pty version: 0.9.0-beta19
- node version: 12.7.0
- Angular-cli version: 8.0.0
- Electron version: 5.0.2
Issue description
I'm using Electron + Angular (clone from https://github.com/maximegris/angular-electron) and I want to implement a simple terminal within the application. Currently I have successfully installed node-pty (after 2 days of struggling) without error (it does show warnings though).
npm install node-pty@0.9.0-beta19 --save
However when I use hot reload, Angular seems can't compile the package as there are some missing packages ??
Date: 2019-08-02T17:52:29.936Z
Hash: 6b9b2529ffe76251176a
Time: 19595ms
chunk {features-repositories-repositories-module} features-repositories-repositories-module.js, features-repositories-repositories-module.js.map (features-repositories-repositories-module) 583 kB [rendered]
chunk {main} main.js, main.js.map (main) 202 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 307 kB [initial] [rendered]
chunk {polyfills-es5} polyfills-es5.js, polyfills-es5.js.map (polyfills-es5) 462 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 8.82 kB [entry] [rendered]
chunk {scripts} scripts.js, scripts.js.map (scripts) 407 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 2.11 MB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 5.43 MB [initial] [rendered]
WARNING in ./node_modules/node-pty/build/Release/conpty.node 1:2
Module parse failed: Unexpected character '�' (1:2)
You may need an appropriate loader to handle this file type.
(Source code omitted for this binary file)
ERROR in ./node_modules/node-pty/lib/windowsPtyAgent.js
Module not found: Error: Can't resolve '../build/Debug/conpty.node' in 'D:\Projects\School_topup\final-pj\node_modules\node-pty\lib'
ERROR in ./node_modules/node-pty/lib/unixTerminal.js
Module not found: Error: Can't resolve '../build/Debug/pty.node' in 'D:\Projects\School_topup\final-pj\node_modules\node-pty\lib'
ERROR in ./node_modules/node-pty/lib/windowsPtyAgent.js
Module not found: Error: Can't resolve '../build/Debug/pty.node' in 'D:\Projects\School_topup\final-pj\node_modules\node-pty\lib'
ERROR in ./node_modules/node-pty/build/Release/pty.node 1:2
Module parse failed: Unexpected character '�' (1:2)
You may need an appropriate loader to handle this file type.
(Source code omitted for this binary file)
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
i 「wdm」: Failed to compile.
Checking node-pty in node_modules, I don't see any debug folder in build.
I did try to rebuild electron (electron-rebuild), re-installing package multiple times (did delete package-lock.json).
Can anyone please help me with this?
#326 is this error related to this issue?
if it's then is there any workaround I wonder?
It's related to that yeah, you're probably compiling it to the wrong arch so it's not loading the Release version. Can you comment out to try/catch where it's loading it (inside node_modules/node-pty) and check the error?
node-pty/src/windowsPtyAgent.ts
Lines 60 to 68 in 8c89c19
It's related to that yeah, you're probably compiling it to the wrong arch so it's not loading the Release version. Can you comment out to try/catch where it's loading it (inside node_modules/node-pty) and check the error?
node-pty/src/windowsPtyAgent.ts
Lines 60 to 68 in 8c89c19
Yes, I just did it and the errors disappeared. Thank you very much.
By the way, is electron suppose to compile node-pty even with binary? Am I doing anything wrong here?... As I know, some people encountered this (different package) and they can fix it but with webpack. Is it a must to have webpack?
Electron must compile the binary, otherwise it won't be able to load. The error you're seeing is related to configuring webpack which I don't know too much about, I think you need to make webpack ignore it or declare it as an external or something.