node-loader
                                
                                 node-loader copied to clipboard
                                
                                    node-loader copied to clipboard
                            
                            
                            
                        Electron not able to read .node files
Im trying to load robotjs with electron but I keep getting an annoying Failed to compile error.
I'm using Vue.js for the interface, if that matters.
The error
 error  in ./node_modules/robotjs/build/Release/robotjs.node
Module parse failed: Unexpected character '�' (1:2)
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)
I tried adding a new rule using node-loader to webpack but that didn't work.
import MiniCssExtractPlugin from "mini-css-extract-plugin";
module.exports = {
  mode: "development",
  devtool: "source-map",
  target: "node",
  node: {
    __dirname: false,
  },
  resolve: {
    extensions: [".ts", ".js"],
  },
  module: {
    rules: [
      {
        test: /\.node$/,
        loader: "node-loader",
      },
      {
        test: /\.ts$/,
        exclude: /node_modules/,
        use: {
          loader: "ts-loader",
        },
      },
      {
        test: /\.scss$/,
        use: [MiniCssExtractPlugin.loader, "css-loader", "sass-loader"],
      },
    ],
  },
  plugins: [new MiniCssExtractPlugin()],
};
This issue was moved from webpack/webpack#14012 by @alexander-akait. Original issue was by @leobezr.
@leobezr Can you provide steps to reproduce?
@leobezr Can you provide steps to reproduce?
Repository
Link to repository
First step
Generate a Vue project with Vue CLI
$ vue create project-name
Configuration used:
- Babel
- Typescript
- Router
- Vuex
- CSS Pre-processors (Scss)
- Unit Testing
- Linter / Formatter
Second step
Add electron to project
$ vue add electron-builder
Third step
Add robotjs to project
$ yarn add robotjs
Fourth step
Import robotjs inside Vue component.
import robot from "robotjs";
That should break the compiler when serving the project.
Sorry, can't run reproducible repo:
make: Entering directory '/home/evilebottnawi/IdeaProjects/bezrbot/node_modules/robotjs/build'
  CXX(target) Release/obj.target/robotjs/src/robotjs.o
cc1plus: warning: command line option ‘-Wbad-function-cast’ is valid for C/ObjC but not for C++
In file included from ../src/keypress.h:6,
                 from ../src/robotjs.cc:7:
../src/keycode.h:112:10: fatal error: X11/Xutil.h: No such file or directory
  112 | #include <X11/Xutil.h>
      |          ^~~~~~~~~~~~~
compilation terminated.
Well thats weird, did you try creating a new repo?
Same problem due robotjs, What is your os and version?
Windows 10 @vue/cli 4.5.11 node v14.16.0
h, weirds, should be compiled... maybe vue-cli already handle node extension, can you check it? just remove loader
h, weirds, should be compiled... maybe vue-cli already handle
nodeextension, can you check it? just remove loader
Can't you just make the changes to try and run it ? I'm not sure what loader you're referring to, is it node-loader?
Also, are you running e:dev for electron build?
I can't run due impossible to install, maybe you can try to reproduce it without vue-cli?
Just wanted to pop in here to share that I'm encountering this same issue. I'm on Windows 11.
@leobezr Is it resolved please? I also have the same problem.
@leobezr Is it resolved please? I also have the same problem.
Not at the time, I just gave up on this project, my suggestion is, if your using robotjs, just use Python instead.
@leobezr All right, thank you.