Current behavior
I know this kind of issue was fixed in the version 5.1.0 but ...
I'm trying to seed DB in the Node JS part logic at the before hook
We have the cls-hooked and 1 more internal npm module for sharing both use async_hooks
When I'm trying to import and use any of that modules I receive crashes at the test script launch:
Error: Webpack Compilation Error
./node_modules/...[our private module name].../lib/...[file name]....js
Module not found: Error: Can't resolve 'async_hooks' in '/Users/.../node_modules/...[private module or cls-hooked].../lib'
resolve 'async_hooks' in '/Users/.../node_modules/...[private module or cls-hooked].../lib'
Parsed request is a module
using description file: /Users/.../node_modules/...[private module or cls-hooked].../package.json (relative path: ./lib)
Field 'browser' doesn't contain a valid alias configuration
resolve as module
Desired behavior
Test script launch should go smoothly with before hook executing
Test code to reproduce
require some module in ./cypress/plugins/index.ts with next similar logic
var async_hooks = require("async_hooks");
var asyncLocalStorage = new async_hooks.AsyncLocalStorage();
...
asyncLocalStorage.getStore();
Cypress Version
^8.1.0 - 8.5.0
Cypress binary version: 8.5.0
Electron version: 13.2.0
Bundled Node version: 14.16.0
tried Node version: 14.17.6 and 16.9.1
the same for:
Cypress binary version: 7.7.0
Electron version: 12.0.0-beta.14
Bundled Node version: 14.15.1
Other
additional install of "async_hooks": "^1.0.0" didn't help
Using TS
"typescript": "^4.1.5"
OS
macOS Big Sur 11.16
The problem was in 1 common file for both processes browser and NodeJs in Cypress.
In this case, Webpack built the bundle with 'browser' context but received NodeJs context logic. That's why the error occured.
When I used enum in Browser part in the file which besides that also exports NodeJs logic it (Webpack) didn't make the 'treeshaking', thus the NodeJs logic was imported into the bundle for browser process logic. 🤷♂️
Related
I have created a brand new react app using VS2022 and create-react-app.
I have installed zlib using npm install zlib.
getting the following error when running npm run start:
ERROR in ./node_modules/zlib/lib/zlib.js 1:0-43
Module not found: Error: Can't resolve './zlib_bindings' in 'c:\projects\mall\mall\node_modules\zlib\lib'
To troubleshoot, I created a test.js file with just require('zlib') in it and it works.
file ./node_modules/zlib/lib/zlib.js has import './zlib_bindings' as a single line in it. But there is no ./zlib_bindings.js.
Questions:
How do I fix this?
How does that work when I run node test.js?
Your test.js file works because you run it with node.
The zlib module provides compression functionality implemented using
Gzip and Deflate/Inflate. It is the part of nodejs core module written
in c++
This module can't be used outside of node.js
You can however try to use react-zlib-js and it should work!
I need to integrate the #serialport library in my electron project but I face this error.
Uncaught Error: Loading non-context-aware native module in renderer: '\?\C:\Users\PC\Desktop\electron_project_X32\node_modules#serialport\bindings\build\Release\bindings.node'
I try to solve it by Making the following changes in the main.js
app.allowRendererProcessReuse = false but no changes
NB: I use those version electron: ^16.1.0 && node: 16.13.2 (32-bit ) && serialport: ^10.4.0,
My Electron app uses a nodejs dependency (in my case it's mysqljs) and it works fine when running on development mode.
However when I build it and launch as a native desktop app, it fails with:
Electron ERROR Error: Cannot find module 'mysql' Require stack: ...
The problem was that I accidentally placed mysql between the devDependencies of my package.json file.
It should instead be placed within the dependencies since it is supposed to be shipped with the app.
My first electron app: it's an admin app intended to run only on my machine
I want to add the #google-cloud/datastore module to it, but electron won't start once I import the package.
I add the package using 'yarn add', then rebuild for electron using electron-rebuild as instructed here: https://electronjs.org/docs/tutorial/using-native-node-modules
The first error is:
Failed to compile
./node_modules/#grpc/grpc-js/build/src/channel.js
Module not found: Can't resolve 'http2' in '<...>\node_modules\#grpc\grpc-js\build\src'
So I try manually yarn add'ing http2, electron-rebuild, and 'yarn start', after which I get a few warnings:
./node_modules/http2/lib/protocol/index.js
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
./node_modules/grpc/src/grpc_extension.js
Critical dependency: the request of a dependency is an expression
./node_modules/grpc/node_modules/node-pre-gyp/lib/pre-binding.js
Critical dependency: the request of a dependency is an expression
./node_modules/grpc/node_modules/node-pre-gyp/lib/util/versioning.js
The app then starts but shows a long list of errors.
Error: Cannot find module './../process/browser.js'
... intermediate errors, below is the module trying to import
Module../node_modules/merge2/index.mjs
I'm not sure if/what I'm doing wrong, or if google datastore is somehow not compatible with electron?
Using the latest Electron & google packages (and no other changes) seems to have resolved this issue
I've tried to compile my opa project with the new release 1.0.1. I'm now using :
node myApp.js
to run the server. I get the following error :
module.js:337
throw new Error("Cannot find module '" + request + "'");
Error: Cannot find module 'mongodb'
Do I need to install a node.js module or something to use mongodb ? My mongodb used to work pretty well with the old native backend.
I've also tried to compile my app with the native backend, and I get that message :
Error: No implementations provided for the following modules:
MailMLRuntime referenced from /usr/lib/opa/stdlib/stdlib.qmlflat/stdlib.web.mail.smtp.client.opx/_build/cstdli
_2eweb_2email_2esmtp_2eclient.cmxa(Bsl_init_stdlib_2eweb_2email_2esmtp_2eclient)
Any idea ?
Thanks
when you launch the compiled node app with node myapp.js, it will look for the node modules in your NODE_PATH.
However, if you launch it with ./myapp.js, it will look at the Opa installation folder first, so that you don't have to install node dependencies yourself :)