Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to import .node #937

Closed
felipe-augusto opened this issue Aug 1, 2020 · 4 comments
Closed

Fail to import .node #937

felipe-augusto opened this issue Aug 1, 2020 · 4 comments

Comments

@felipe-augusto
Copy link

Throws an error when trying to build:

Running the build script…
yarn run v1.22.4
$ vue-cli-service build

-  Building for production...
 ERROR  Failed to compile with 1 errors6:34:17 PM

 error  in ./node_modules/robotjs/build/Release/robotjs.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)
 ERROR  Build failed with errors.

 @ ./node_modules/robotjs/index.js 1:14-53

Here's my vue.config.js:

module.exports = {
  pluginOptions: {
    electronBuilder: {
      nodeIntegration: true,
      externals: ['iohook'],
      chainWebpackMainProcess: config => {
        config.module.rule('node').test(/\.node$/).use('node-loader').loader('node-loader').end()
      },
      chainWebpackRendererProcess: config => {
        config.module.rule('node').test(/\.node$/).use('node-loader').loader('node-loader').end()
      },
    }
  }
}
@nklayman
Copy link
Owner

nklayman commented Aug 2, 2020

Try marking robotjs as an external:

// in vue.config.js
module.exports = {
  pluginOptions: {
    electronBuilder: {
      externals: ['robotjs']
    }
  }
}

@felipe-augusto
Copy link
Author

@nklayman Thank you for you reply! I've just tried with the following config:

module.exports = {
  pluginOptions: {
    electronBuilder: {
      nodeIntegration: true,
      externals: ['iohook', 'robotjs']
    }
  }
}

Got the same error:

$ electron-builder install-app-deps
  • electron-builder  version=22.8.0
  • rebuilding native dependencies  dependencies=robotjs@0.6.0 platform=linux arch=x64
  • install prebuilt binary  name=robotjs version=0.6.0 platform=linux arch=x64
  • build native dependency from sources  name=robotjs
                                          version=0.6.0
                                          platform=linux
                                          arch=x64
                                          reason=prebuild-install failed with error (run with env DEBUG=electron-builder to get more information)
                                          error=prebuild-install info begin Prebuild-install version 5.3.5
    prebuild-install info looking for cached prebuild @ /home/runner/.npm/_prebuilds/71407d-robotjs-v0.6.0-electron-v76-linux-x64.tar.gz
    prebuild-install http request GET https://github.com/octalmage/robotjs/releases/download/v0.6.0/robotjs-v0.6.0-electron-v76-linux-x64.tar.gz
    prebuild-install http 404 https://github.com/octalmage/robotjs/releases/download/v0.6.0/robotjs-v0.6.0-electron-v76-linux-x64.tar.gz
    prebuild-install WARN install No prebuilt binaries found (target=8.3.4 runtime=electron arch=x64 libc= platform=linux)
    
  • rebuilding native dependency  name=robotjs version=0.6.0
Done in 65.29s.

Running the build script…
yarn run v1.22.4
$ vue-cli-service build

-  Building for production...
 ERROR  Failed to compile with 1 errors1:20:12 PM

 error  in ./node_modules/robotjs/build/Release/robotjs.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/robotjs/index.js 1:14-53

@nklayman
Copy link
Owner

nklayman commented Aug 5, 2020

Just tested it myself and in addition to marking it as an external, I also had to add app.allowRendererProcessReuse=false to background.js, because of octalmage/robotjs#580.

@nklayman nklayman closed this as completed Aug 5, 2020
@felipe-augusto
Copy link
Author

@nklayman thank you so much for your help

I was able to grab a Linux computer and it compiled like a charm, it turns out there is something wrong in my GitHub Action that is giving that error. I'll investigate what is causing that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants