In some popular NodeJS libraries, e.g. ssh2 or node-pty, there is natively compiled code as part of the library. Creating the project with
vue create my-project
vue add electron-builder
yarn add ssh2
then importing and using ssh2's Client
in the background process results in following errors during
electron:build
ERROR Failed to compile with 1 errors 5:29:10 PM
error in ./node_modules/cpu-features/build/Release/cpufeatures.node
Module parse failed: Unexpected character '�' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)
@ ./node_modules/cpu-features/lib/index.js 1:16-60
@ ./node_modules/ssh2/lib/protocol/constants.js
@ ./node_modules/ssh2/lib/client.js
@ ./node_modules/ssh2/lib/index.js
...
This error occurs with many other libs or transitive dependencies and the reason for it is absence of native-ext-loader
on Webpack chain. I understand why it is not included by default, and I would like to see what is the best way to add it.