npm install creating files at wrong directory for electron - node.js

When I install sqlite3by npm in directory of electron project,
it creates
c:\testing\Elektron\node_modules\sqlite3\lib\binding\node-v57-win32-x64
but electron aplication throw following error:
Error: Cannot find module 'c:\testing\Elektron\node_modules\sqlite3\lib\binding\electron-v1.6-win32-x64\node_sqlite3.node'
I tried to rename the directory, but it lead to
Error: A dynamic link library (DLL) initialization routine failed.
Here is the pastebing of all commands and actions I did
I don't need work arounds, I need to build aplication later into an executable file, so I appreciate your answer.

electron-rebuild
is needed for native modules.

Related

Can't create a react native empty project, app.json not found

I am currently trying to get started with react native.
I set up the development environment referring to the documentation, but can't even pass the first step and create an empty project.
I am on Windows 11, Node 16.15.1, and NPM 8.12.2
I keep getting the following error when trying to init react-ative project with expo init awesomeProject
Error downloading and extracting template package: Error: npm exited with non-zero code: 1
× Something went wrong while downloading and extracting the template.
Can't read JSON file: D:\crna\awesomeProject\app.json
└─ Cause: Error: ENOENT: no such file or directory, open 'D:\crna\awesomeProject\app.json'
Does anyone has a suggestion ?
Don't really know what is the problem but i found a soluion that might help other people in the same situation as me! like said here just run in CMD instead of GitBash
Use sudo if on linux. And maybe Admin on windows.

native module compile error on ubuntu for node-webcrypto-ossl on electron project

I am trying to use https://www.npmjs.com/package/node-webcrypto-ossl this module in an electron project.
When I try to build it gives me following error.
g++: error: /home/username/.electron-gyp/.node-gyp/4.0.0/deps/openssl/openssl/lib/libcrypto.a: No such file or directory
nodessl.target.mk:167: recipe for target 'Release/obj.target/nodessl.node' failed
This module works ok in node only project.
It appears the openssl dependency is missing, were dependencies installed?

Azure Function 'unable to find module' after following installation instructions

I'm trying trying to use a node module inside my Azure Functions project. I've tried following these instructions several times but still can't use the module I'm trying to bring in.
After bringing in my package.json and running npm install, I can see the node_modules folder (actual modules are located in node_modules/.staging). Upon restarting the function and trying to run it, I get Error: Cannot find module '_____'.
I'm following the instructions correctly. Any suggestions on how to get the modules to work?
You did everything correctly, after npm install, please wait for some time. Modules being in ./staging folder means the installation is still in progress.
You will see added packages prompt in console after the installation is finished.
Update--Avoid long time waiting for module install.
As #brettsam mentioned in comment, with azure-functions-pack tool(also a module), we can place all the modules in a single file, no need to install online and wait. You can search for your function name to find your function scripts if you want to edit after publication.

Cannot find module './build/Release/hdf5' in Electron

I installed the hdf5 node library, and it looked like it is in place. I am able to type require('hdf5') in command line, but when I run the electron wrapper, it gives me the error: Cannot find module './build/Release/hdf5'.
What could be the problem?
Even though the module is in my local directory, when I run the code with Electron, There is not such module under node_module.
Screenshot

How to include node-sass in nwjs (on windows)

I'm working on a multi-platform project in NW.js (node-webkit) and it has to use node-sass. The problem is that I can't seem to find any way to include it without an error on windows (x64).
Here's what I've tried:
Require as is
Error: A dynamic link library (DLL) initialization routine failed.
Build with node-sass' built in script and then require
Error: A dynamic link library (DLL) initialization routine failed.
Build with node-gyp
Error: A dynamic link library (DLL) initialization routine failed.
Build with nw-gyp (configure command fails)
Error: name 'component' is not defined while evaluating condition 'OS=="win" and component=="shared_library" in binding.gyp while trying to load binding.gyp
I've tested this on Windows 10 (x64), node v6.5.0, NW.js v0.16.1 and v0.17.0, node-sass (latest).
Thanks for your help!
I faced similar issue (but on linux) and failed to find any answer why node-sass does not work and how to fix it. But sass.js works for me (worker+script). Of course it isn't so convenient as node-sass (i.e you need to handle imports in a special way), but for my needs it works fine.
What I ended up doing is:
I created a wrapper around node-sass that calls node-sass as a child process (through the cli).
const { exec } = require('child_process');
module.exports = function (options, cb) {
// turn the options to node-sass cli args
// something like this...
exec(`node-sass ${agrs}`, execOptions, cb);
}
Works like a charm! ;)

Resources