opa 1.01 : node.js -> Error: Cannot find module 'mongodb' - node.js

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 :)

Related

How do I use zlib in a react app? or what is zlib_binding and why is it missing?

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!

Cypress - Error: Can't resolve 'async_hooks'

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. 🤷‍♂️

sails js running testProjects issue in ubuntu

I am new to nodejs and after installing sails when i try to run it, using command sails lift, it gives me below error. Need help to resolve it.
/usr/lib/node_modules/sails/node_modules/waterline/node_modules/lodash/index.js:692
function runInContext(context) {
^
illegal access
It was an issue with the version of node i was using v0.11.13. I have changed the version and it started working.

'require' statement in index.js causes error saying mailchimp module cannot be found

I'm using this API for a web app I'm making that uses mailchimp:
Here's the node.js API page
I'm also using this git repo to understand how to use the API: example repo
I cloned the repo, ran npm install express in the express directory of the repo, then ran node app
when I did that, I got this error: Error: Cannot find module './node_modules/mailchimp-api/mailchimp'
The require statement that names this module (in index.js) is:
var mcapi = require('./node_modules/mailchimp-api/mailchimp');
I checked the path, it should be correct. is there something I'm missing?
You need to run npm install in the express directory of the repo so that all of the modules are installed. You are missing the mailchimp module.

Node js Error: Unable to load shared library

I'm trying to require any NodeJs addon that used "node-waf configure build" when installed with no luck. I keep getting the same message:
Error: Unable to load shared library /Users/xxxx/node_modules/pdfkit/node_modules/flate/lib/zlib_bindings.node
Error: Unable to load shared library /Users/xxxx/node_modules/rsa/rsaBinding.node
Error: Unable to load shared library /Users/xxxx/node_modules/dcrypt/build/default/dcrypt.node
addons I tried:
pdfkit, rsa, dcrypt
I'm on MacOsx 10.6.8, nodejs v0.6.5, npm .1.0-alpha-6
I encountered same problem with bcrypt and found it's because my node was 32bit and bcrypt was build as 64bit. After I build a 64bit node, all things work fine now.
PDFKit now uses the builtin zlib module from Node instead of the old flate dependency.

Resources