Native modules used inside plugin fails on Window
See original GitHub issueCurrent 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:
- Created 4 years ago
- Comments:8 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 donpm install xml2json
, it might work.#4436 should resolve this by using your system Node for the custom reporter.
@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?