A dynamic link library (DLL) initialization routine failed in electron with nodegit - node.js

When I use nodegit in electron, I got the error when I start the app:
App threw an error during load
Error: A dynamic link library (DLL) initialization routine failed.
\?\D:\Electron\hello\node_modules\nodegit\build\Release\nodegit.node
at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:166:20)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:740:18)
...
I can use nodegit in nodejs successfully, but failed in electron.
Even I added .npmrc file with content below, it's still faield.
runtime = electron
target = 1.2.8
target_arch = x64
disturl = https://atom.io/download/atom-shell
Does anyyone know how to fix it in electron?
My environment is windows 10 x64 with vs 2017, node 10.13, electron 3.010

I had the same problem with another node package using electron 3.0.6 and eventually got it working.
Try these:
Make sure the packages are listed under the dependencies and not devDependencies in the package.json
Add this "electron-rebuild --force node-gyp rebuild --target=3.0.6 --arch=x64" to postinstall under the scripts section. I ended up with this in my packages.json (my DLL error was for "printer")
{
"name": "myproject",
"version": "1.0.0",
"main": "main.js",
"scripts": {
"postinstall": "electron-rebuild --force node-gyp rebuild --target=3.0.6 --arch=x64",
"start": "electron ."
},
"dependencies": {
"#types/node": "^10.12.18",
"electron-rebuild": "1.8.2",
"electron": "3.0.6",
"printer": "0.2.2"
},
"devDependencies": {
...
}
}
See here for more info
Hope this helps someone

From this link:
The most common issue though is that the component was not properly installed, so that some of its dependencies are not available.

First confirm if global node version matches with the project one. Some projects require specific version hence first delete other node and install required node version and project dependencies. Try below solutions to solve the errors as same worked for me
Clean up node modules [ https://medium.com/#mariokandut/how-to-clean-up-node-modules-5aed676156db ] and rebuild the project. It rebuilds node_modules folder
Since it is an electron app try yarn electron-rebuild. For more info on yarn refer " https://www.digitalocean.com/community/tutorials/how-to-install-and-use-the-yarn-package-manager-for-node-js "
If electron rebuild fails check if "Visual C++ Build Environment" are installed. Refer https://stackoverflow.com/a/61252536/9558119 for same.
Rerun electron rebuild and then run build as per your project

Related

why I can't change Typescript version even though I have downgraded the version

so previously, I installed Typecript on my new macbook by running this command
sudo npm install typescript -g
and I got Typescript version 4.7.4. and then I want to deploy the function using this command
firebase deploy
unfortunately, there is a warning like this
WARNING: You are currently running a version of TypeScript which is
not officially supported by #typescript-eslint/typescript-estree.
You may find that it works just fine, or you may not.
SUPPORTED TYPESCRIPT VERSIONS: >=3.3.1 <4.1.0
YOUR TYPESCRIPT VERSION: 4.7.4
Please only submit bug reports when using the officially supported
version.
and then I downgrade to version 4.0.7, but unfortunately that warning still exist, it seems my app is still on v4.7.4 (cached ? ) I am sure I have changed the typescript version on package.json and I also check via terminal like the image below
but why my node app still have version v.4.7.4 ? not v.4.0.7 ? what should I do?
fiuhhh....after 2 days, I finally find the solution
I have to change the dependencies and also the devDependencies, especially these dependencies in the package.json
"dependencies": {
"firebase-admin": "^10.0.2",
"firebase-functions": "^3.18.0",
},
"devDependencies": {
"#typescript-eslint/eslint-plugin": "^5.12.0",
"#typescript-eslint/parser": "^5.12.0",
"eslint": "^8.9.0",
"eslint-config-google": "^0.14.0",
"eslint-plugin-import": "^2.25.4",
"typescript": "^4.5.4" // <-- watch this version
},
the problem is ....it seems to me that these dependencies is tightly coupled. it can easily break if it doesn't match. so my solution is to create new project just to copy and paste those dependencies combination above with the latest version recommended by firebase. watch this video if you are confused how to initialize cloud function project
first, Update your firebase tools to the latest version using this command
sudo npm install -g firebase-tools
and change to your directory and init the project
cd desktop
mkdir forCopyPasteDependenciesOnly
firebase init
select cloud function and typescript. and then you copy those dependencies above and paste it on your problematic project
in my case, I also change the typescript globally using the recommended typescript version from the project package.json that you just initialize (4.5.4, not 4.0.7 or 4.7.4 in my case )
sudo npm uninstall -g typescript
sudo npm install -g typescript#4.5.4
and then, in your problematic project, delete your node-modules folder
and delete your package-lock.json. and finally run these 2 commands below
npm cache clean –force
npm install
and when you run firebase deploy you may see errors, but luckily it just error from eslint you just update, you can solve it easily.
I hope it helps
You installed typescript as globally on your system but you changed just in your package.json.
First you should type this npm uninstall -g typescript.
Then npm install -g typescript#your version.
After that you can uninstall your local tsc on your project.

Parcel SemVer bug

So, I've used Parcel multiple times before and I've never had an issue with it.
This time it throws some stupid errors about SemVer versioning and I'm literally loosing my mind trying to find a solution which would fix this problem.
I've started new project: installed npm w/ npm init (no additional options), then installed parcel npm install --save-dev parcel-bundler and then created my folder structure:
--node_modules
--index.html
--index.js
Here is my package.json:
{
"name": "playground",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "parcel index.html"
},
"author": "",
"license": "ISC",
"devDependencies": {
"parcel-bundler": "^1.12.4"
}
}
I've configured default npm script to run parcel: "dev": "parcel index.html" and run it.
Everything works fine, however when I connect my index.js in index.html via <script src="/index.js"></script> it throws big fat error, saying:
D:\workingSpace\playground\index.js: Invalid Version: undefined
at new SemVer (D:\workingSpace\playground\node_modules\#babel\preset-env\node_modules\semver\semver.js:314:11)
at compare (D:\workingSpace\playground\node_modules\#babel\preset-env\node_modules\semver\semver.js:647:10)
at lt (D:\workingSpace\playground\node_modules\#babel\preset-env\node_modules\semver\semver.js:688:10)
at D:\workingSpace\playground\node_modules\#babel\preset-env\lib\index.js:276:22
at Object.default (D:\workingSpace\playground\node_modules\#babel\helper-plugin-utils\lib\index.js:22:12)
at getEnvPlugins (D:\workingSpace\playground\node_modules\parcel-bundler\src\transforms\babel\env.js:62:34)
at getEnvConfig (D:\workingSpace\playground\node_modules\parcel-bundler\src\transforms\babel\env.js:12:25)
at async getBabelConfig (D:\workingSpace\playground\node_modules\parcel-bundler\src\transforms\babel\config.js:32:19)
at async babelTransform (D:\workingSpace\playground\node_modules\parcel-bundler\src\transforms\babel\transform.js:6:16)
at async JSAsset.pretransform (D:\workingSpace\playground\node_modules\parcel-bundler\src\assets\JSAsset.js:83:5)
Currently I'm using Node v14.6.0 and accordingly it's npm version - 6.14.11
I've never faced this bug before, please help T_T
This is a known problem in the newest version of Parcel.
The solution of this problem was to revert back to version 1.12.3, or by updating to the version 2 of Parcel. You can do the first solution by:
npm uninstall parcel-bundler
npm i --save-dev parcel-bundler#1.12.3
The second solution could be done like this:
npm i --save-dev parcel#next
You might have to refactor your code a bit to prevent breaking changes if you decided to use the nightly version of Parcel. Check more about how to migrate to Parcel v2 / nightly here.
Catch up with that issue here.
Update #1: 28/05/2021
It seems that Parcel team has been working on a fix, as of the time of writing (28/05/2021). While I have not personally checked if the update has worked properly or not, this answer is still very much a viable and feasible solution.
I have recently went through this issue, where parcel#1.12.4 kept throwing Invalid Version: undefined even after trying a very logical workound posted on GitHub #5943.
Installing parcelV2 worked in my case. If anyone else is facing a similar problem, I would recommend trying the following steps:
npm uninstall -D parcel-bundler
npm install -D parcel#next
npx parcel serve index.html

npm error - verify that the package.json has a valid "main" entry

Im playing around with a simple trading bot using binance and cctx
when i run my script with node index.js
i get this long error:
internal/modules/cjs/loader.js:323
throw err;
^
Error: Cannot find module '/home/ether/Documents/nodesendeth/node_modules/cctx/index.js'. Please verify that the package.json has a valid "main" entry
at tryPackage (internal/modules/cjs/loader.js:315:19)
at Function.Module._findPath (internal/modules/cjs/loader.js:703:18)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:967:27)
at Function.Module._load (internal/modules/cjs/loader.js:862:27)
at Module.require (internal/modules/cjs/loader.js:1040:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/home/ether/Documents/nodesendeth/index.js:2:14)
at Module._compile (internal/modules/cjs/loader.js:1151:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1171:10)
at Module.load (internal/modules/cjs/loader.js:1000:32) {
code: 'MODULE_NOT_FOUND',
path: '/home/ether/Documents/nodesendeth/node_modules/cctx/package.json',
requestPath: 'cctx'
}
so it basically cant find the cctx module
cctx was installed with npm i cctx and i also ran npm install afterwards just to make sure.
It also says verify that package.json file has a valid main entry, which it does:
{
"name": "nodesendeth",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"cctx": "^1.0.1",
"dotenv": "^8.2.0"
}
}
I pasted the code to my script here
https://paste.ubuntu.com/p/p4n6MH3vbn/
Also my await functions arent working- even though i use them in an async function
So Im not a 100% sure what exactly the error is, there is a main entry in the package.json file and the cctx module has been installed
For me removing my node_modules folder and running npm i solve the problem
Delete node_modules
Run "npm i"
Fixed
For me, the cause was that I accidentally hit STRG + C while installing all the modules, which broke something.
If you are working with firebase functions, and you are using TypeScript, check the path to the generated index.js after npm run build.
In my case it was lib/functions/src/main.js.
setting:
"main": "lib/functions/src/index.js",
on package.json fixed the issue
https://www.npmjs.com/package/cctx <- Not a valid package. It's a typo for this package: https://www.npmjs.com/package/ccxt (CCXT instead of CCTX). Install that instead. The issue isn't with your code, it's that you installed the wrong package.
If you are working with firebase functions, and you are using TypeScript,
run the
npm run build
inside the Function directory
after that, a folder is generated in the current folder lib
then return back and fire!
$ firebase deploy
Run npm update, it will fix the issue
Or you can also delete node_modules and the package-lock.json file then npm install will also solve the issue.
In my case, I was getting this error from my VS Code ESLint plugin output. However running the linter through the terminal was just fine. After exhausting other options, restarting VS Code did the trick and ESLint plugin runs.
I have also faced the same Problem earlier.
I solved the problem by deleting the nodemodules folder and then
npm update
then
npm install
node:internal/modules/cjs/loader:361 throw err; ^
Error: Cannot find module '/Users/node_modules/express/server.js'. Please verify that the package.json has a valid "main" entry
fixed the above error - by making sure the express.js was added into my package.json as a dependency.
"dependencies": { "ejs": "^3.1.6", "express-ejs": "^2.0.0", "express-ejs-layouts": "^2.5.1", "express.js": "^1.0.0" },
I have faced the same issue once when the packages didn't install properly.
Add fixed this by reinstalling packages after deleting the node_modules folder.
this worked for me :
first uninstall node and go to the installation directory (C:\Program Files\nodejs)
and remove every file and folder there.
reinstall node

Handling version incompatibility in npm dependencies

Some context
Every time VS Code is released built on a new version of Node, the VS Code Arduino extension breaks until a new version is released.
Having cloned the Arduino extension git repo I uninstalled it as an extension and ran it in the debugger. This worked and now I have specific intel, if only I knew how to act on it. This is the message:
[Warn] no library available after trying files native_loader.js
undefined
Array[3]
0
"d:/vscode-arduino/out/node_modules/node-usb-native/lib/native/detector_darwin_7.1.11_x64.node"
1
"d:/vscode-arduino/out/node_modules/node-usb-native/lib/native/detector_Ubuntu14.04_7.1.11_x64.node"
2
"d:/vscode-arduino/out/node_modules/node-usb-native/lib/native/detector_win32_7.1.11_x64.node"
rejected promise not handled within 1 second: Error: The module '\\?\d:\vscode-arduino\out\node_modules\usb-detection\build\Release\detection.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 72. This version of Node.js requires
NODE_MODULE_VERSION 80. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
extensionHostProcess.js
stack trace: Error: The module '\\?\d:\vscode-arduino\out\node_modules\usb-detection\build\Release\detection.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 72. This version of Node.js requires
NODE_MODULE_VERSION 80. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
The last of these files (the Windows x64 one) is indeed present on the expected path so "no library available" doesn't mean it can't find the file. This agrees with the end of the message which reports that no suitable version can be found.
The end of this message suggests npm rebuild or npm i so I tried those to no avail.
Rummaging in package.json revealed
"scripts": {
"vscode:prepublish": "gulp build --mode=production",
"postinstall": "cd ./src/views && npm install && node ../../node_modules/node-usb-native/scripts/rebuild-serialport.js",
"test": "gulp test"
},
"extensionDependencies": [
"ms-vscode.cpptools"
],
"devDependencies": {
"#types/compare-versions": "^3.0.0",
...
"webpack": "^4.44.1"
},
"dependencies": {
...
"node-usb-native": "0.0.13",
...
}
The dependency on node-usb-native is behind the latest (0.0.15). Changing this and running npm i triggers the post-install task to rebuild-serialport.js which appears to succeed, but I get the same error at runtime.
The question
How do I resolve this?
What exactly needs rebuilding? usb-detection isn't listed in the dependencies (or the devDependencies) but if I'm not mistaken node-usb-native depends on it.
How do I go about this such that the code complaining about
versions sees the freshly minted bits?

Can't install laravel-elixir because of node-sass failure

I am pretty new to this environment still and am trying to get up to speed on node.js modules and Laravel (5.1.11) as a whole, so...
I have a fresh install of Laravel implemented by the cPanel Installitron. I'm using PHPStorm to install all of the node modules via the provided package.json:
package.json
{
"private": true,
"devDependencies": {
"gulp": "^3.8.8"
},
"dependencies": {
"laravel-elixir": "^3.0.0",
"bootstrap-sass": "^3.0.0"
}
}
The error I get when I run the install is:
Cannot download "https://github.com/sass/node-sass/releases/download/v3.13.1/win32-x64-57_binding.node":
HTTP error 404 Not Found
I can understand why this would happen, seeing as that is an older version of node-sass, but how do I know what newer versions are compatible with the requested version of laravel-elixir? I didn't want to just install a newer version of node-sass because digging a deeper hole would make it harder for me to find a solution to my problem. What is the fix for this?
It looks like you can fix this by installing Windows Build Tools via this command:
npm install --global --production windows-build-tools
Then delete the project's node_modules folder and re-run npm install.
Just follow this official url well doc.: https://laravel.com/docs/5.3/elixir if you get any error. I just comment and i ll be here.

Resources