question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Native modules used inside plugin fails on Window

See original GitHub issue

Current behavior:

Using native modules inside the pluginsfile (plugins/index.js) will throw DLL initialization fail error on Windows.

Desired behavior:

Should be able to use native modules inside plugins file

Steps to reproduce: (app code and test code)

Inside the pluginsfile, I am requiring the serialport module.

const serialport = require('serialport');

Below is the error. Also, Cypress was configured to run in Chrome.

Error: A dynamic link library (DLL) initialization routine failed.
\\?\C:\Code\project\node_modules\@serialport\bindings\build\Release\bindings.node
    at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:172:20)
    at Object.Module._extensions..node (module.js:598:18)
    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:172:20)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at bindings (C:\Code\project\node_modules\bindings\bindings.js:112:48)
    at Object.<anonymous> (C:\Code\project\node_modules\@serialport\bindings\lib\win32.js:1:191)
    at Object.<anonymous> (C:\Code\project\node_modules\@serialport\bindings\lib\win32.js:111:3)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)

Versions

Cypress Version: 3.1.0 OS: Windows 10 Browser: Chrome v74.0.3729.131 Node: v8.15.1

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
flotwigcommented, Sep 5, 2019

This is most likely because Cypress uses the version of Node bundled with Electron (8.9.3) which is different than the version of node that node-expat was installed for.

If you clear node_modules and use Node 8.9.3 to do npm install xml2json, it might work.

#4436 should resolve this by using your system Node for the custom reporter.

1reaction
qtphan734commented, May 22, 2019

@jennifer-shehane I am using serialport to control a device before running tests. However, I believe this apply to any native modules, not just serialport. Based on my understanding, when you perform npm install, it builds native modules against the Node.js version that was installed on your machine, not that of Electron project (eg. Cypress).

In my previous projects, I would rebuild all native modules for Electron using the below module: https://github.com/electron/electron-rebuild

Is there some way this could be implemented in Cypress?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Requiring module "node_modules\react-native-reanimated ...
You have to add 'react-native-reanimated/plugin', in the babel.config.js file so the ... I updated to @2.11.0 and it fixed my compile error.
Read more >
Troubleshooting Common Errors - Gatsby
A common problem that trips up users that install and begin to use styled-components or emotion is not including the related plugin in...
Read more >
Module Federation - webpack
This object is used as a shared scope in the remote container and is filled with the provided modules from a host. It...
Read more >
Troubleshooting | React Navigation
If the module points to an npm package (i.e. the name of the module doesn't with ./ ), then it's probably due to...
Read more >
Features | Vite
Native ES imports do not support bare module imports like the following: ... Vue users should use the official @vitejs/plugin-vue-jsx plugin, which provides ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found