I've createed simple native add-on using generator-napi-module. The module is successfully built.
Also, I've added folowing line in window.js:
const testmodule = require('testmodule')
When I start app with npm start, I've got following error:
ELECTRON_ASAR.js:166 Uncaught Error: A dynamic link library (DLL) initialization routine failed.
\\?\C:\Electron\simple-samples-master\activity-monitor\node_modules\testmodule\build\Release\testmodule-native.node
at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:166:20)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:740)
at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:166:20)
at Module.load (internal/modules/cjs/loader.js:620)
at tryModuleLoad (internal/modules/cjs/loader.js:559)
at Function.Module._load (internal/modules/cjs/loader.js:551)
at Module.require (internal/modules/cjs/loader.js:658)
at require (internal/modules/cjs/helpers.js:20)
at Object.<anonymous> (C:\Electron\simple-samples-master\activity-monitor\node_modules\testmodule\lib\binding.js:1)
at Object.<anonymous> (C:\Electron\simple-samples-master\activity-monitor\node_modules\testmodule\lib\binding.js:6)
The module is working properly when I execute command:
node index
or test with:
npm test
What could go wrong here? Could this be related to security?
Also note that I tried to play with ffi-napi to load native library but the same error message appears.
Related
I'm getting below error when trying to launch the application.
This is after I deleted node_modules and re-ran npm i to pull packages again
App threw an error during load
node_modules/electron/dist/resources/default_app.asar/main.js:113
Error: Cannot find module '/home/korodarn/projects/mygit/sight-words-solid-electron/node_modules/stt/lib/binding/v1.4.0/linux-x64/electron-v17.4/stt.node'
Require stack:
- /home/korodarn/projects/mygit/sight-words-solid-electron/node_modules/stt/index.js
- /home/korodarn/projects/mygit/sight-words-solid-electron/dist/main/index.cjs
- /home/korodarn/projects/mygit/sight-words-solid-electron/node_modules/electron/dist/resources/default_app.asar/main.js
-
at Module._resolveFilename (node:internal/modules/cjs/loader:940:15)
at Function.n._resolveFilename (node:electron/js2c/browser_init:249:1105)
at Module._load (node:internal/modules/cjs/loader:785:27)
at Function.c._load (node:electron/js2c/asar_bundle:5:13343)
at Module.require (node:internal/modules/cjs/loader:1012:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/home/korodarn/projects/mygit/sight-words-solid-electron/node_modules/stt/index.js:24:17)
at Module._compile (node:internal/modules/cjs/loader:1116:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1169:10)
at Module.load (node:internal/modules/cjs/loader:988:32)
I've tried electron-rebuild ( invoked with node_modules/.bin/electron-rebuild ) and it completes successfully but it seems to only rebuild the canvas dependency based on the output.
I am not able to follow the coqui stt documentation well enough to know where to go next.
I have an issue with the deployment of a node app to production.
When I try to execute with Node a script I get the following error:
internal/modules/cjs/loader.js:498
throw new ERR_PACKAGE_PATH_NOT_EXPORTED(basePath, mappingKey);
^
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './dist/pako.es5.js' is not defined by "exports" in /opt/iul/sat_web_lfr/node_modules/pizzip/node_modules/pako/package.json
at applyExports (internal/modules/cjs/loader.js:498:9)
at resolveExports (internal/modules/cjs/loader.js:514:23)
at Function.Module._findPath (internal/modules/cjs/loader.js:642:31)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1017:27)
at Function.Module._load (internal/modules/cjs/loader.js:899:27)
at Module.require (internal/modules/cjs/loader.js:1090:19)
at require (internal/modules/cjs/helpers.js:75:18)
at Object.<anonymous> (/opt/iul/sat_web_lfr/node_modules/pizzip/js/flate.js:5:12)
at Module._compile (internal/modules/cjs/loader.js:1201:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1221:10)
at Module.load (internal/modules/cjs/loader.js:1050:32)
at Function.Module._load (internal/modules/cjs/loader.js:938:14)
at Module.require (internal/modules/cjs/loader.js:1090:19)
at require (internal/modules/cjs/helpers.js:75:18)
at Object.<anonymous> (/opt/iul/sat_web_lfr/node_modules/pizzip/js/compressions.js:14:19)
at Module._compile (internal/modules/cjs/loader.js:1201:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1221:10)
at Module.load (internal/modules/cjs/loader.js:1050:32)
at Function.Module._load (internal/modules/cjs/loader.js:938:14)
at Module.require (internal/modules/cjs/loader.js:1090:19)
at require (internal/modules/cjs/helpers.js:75:18)
at Object.<anonymous> (/opt/iul/sat_web_lfr/node_modules/pizzip/js/utils.js:7:20) {
code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}
However when I execute this script on the testing server works fine.
We even copy and paste the node modules folder from the testing server to the production server but the error is the same.
I think is an error in some external package but I don't understand how the same configuration can have this kind of error depending on the system.
I've tried to update npm from 6.14.5 to 7.23.0 but the error persists.
Both testing and production server uses the same version of Node, 14.X
The only possibility remaining is that I'm using a different NODE_ENV variable between the 2 servers but looking at the error message it's seems unlikely.
Thanks in advance.
When I run npx webpack on my project, I get the following error:
[webpack-cli] Failed to load '/the/path/to/my/project/webpack.config.babel.js' config
[webpack-cli] TypeError: String.prototype.startsWith called on null or undefined
at startsWith (<anonymous>)
at node:internal/errors:811:19
at Array.filter (<anonymous>)
at node:internal/errors:809:16
at prepareStackTrace (node:internal/errors:96:12)
at Module._extensions..js (node:internal/modules/cjs/loader:1138:38)
at Object.newLoader [as .js] (/the/path/to/my/project/node_modules/pirates/lib/index.js:104:7)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
As you can see from the error, I have a webpack.config.babel.js file and a .babelrc file for configuration.
I've attempted to debug the build, but the variable content I get on the exception breakpoint is not very informative.
It looks like I was about to get a useful error message, but then a string came back null, so the error didn't get printed at all.
Rename .babelrc to .babelrc.json, and the build succeeds.
I've developed an electron app with following tech stack:
NodeJS (10.15) with Babel to allow ES6 import/export syntax.
Sequelize on SQLite and GraphQL to handle an internal database.
ReactJS (bundled) for views.
I've configured everything to work with Electron and running "electron" command in project root folder works without errors.
Now i'm trying to distribute it using this tutorial: https://electronjs.org/docs/tutorial/application-distribution
So i've simply downloaded the 4.1.4 binaries for windows and moved the project folder under resources/app/
But running the electron.exe i've the following error:
App threw an error during load
TypeError: Cannot create property 'default' on symbol 'Symbol(nodejs.util.inspect.custom)'
at Object.<anonymous> (C:\workspace\myapp\resources\app\node_modules\graphql\jsutils\nodejsCustomInspectSymbol.js:18:84)
at Object.<anonymous> (C:\workspace\myapp\resources\app\node_modules\graphql\jsutils\nodejsCustomInspectSymbol.js:20:3)
at Module._compile (internal/modules/cjs/loader.js:711:30)
at Module._compile (C:\workspace\myapp\resources\app\node_modules\pirates\lib\index.js:83:24)
at Module._extensions..js (internal/modules/cjs/loader.js:722:10)
at Object.newLoader [as .js] (C:\workspace\myapp\resources\app\node_modules\pirates\lib\index.js:88:7)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:559:12)
at Function.Module._load (internal/modules/cjs/loader.js:551:3)
at Module.require (internal/modules/cjs/loader.js:658:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (C:\workspace\myapp\resources\app\node_modules\graphql\jsutils\defineToJSON.js:8:57)
at Object.<anonymous> (C:\workspace\myapp\resources\app\node_modules\graphql\jsutils\defineToJSON.js:36:3)
at Module._compile (internal/modules/cjs/loader.js:711:30)
at Module._compile (C:\workspace\myapp\resources\app\node_modules\pirates\lib\index.js:83:24)
at Module._extensions..js (internal/modules/cjs/loader.js:722:10)
at Object.newLoader [as .js] (C:\workspace\myapp\resources\app\node_modules\pirates\lib\index.js:88:7)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:559:12)
at Function.Module._load (internal/modules/cjs/loader.js:551:3)
at Module.require (internal/modules/cjs/loader.js:658:17)
at require (internal/modules/cjs/helpers.js:20:18)
i've also tried to run npx electron resources/app/ from binaries folder and i've got the same error.
So i think the issue is something about the paths.
i've also tried electron-packager and the error is the same because this tool does the same process of guide above.
What can i do to fix it?
UPDATE1: after some investigations i've found that babel causes the issues. I guess when you run a project from a parent folder. I'm trying to find a solution
i've solved using this kind of configuration for babel/register:
const rootPath=path.resolve(path.join(__dirname, "../../"));
require("#babel/register")({
root: rootPath,
extends: path.join(rootPath, '.babelrc'),
ignore: [/node_modules/],
only: [rootPath],
})
Context: I am building an electron app, which is querying a sql server (remote server) to get the data from table. I am using mssqlnodev8.
Error: When I start the electron app using npm start, I get the below error -
Uncaught Error: None of the binaries loaded successfully. Is your node
version either latest 4, 5, 6, 7, 8 or 9 ?
at failIfNoBinaryExported (C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bootstrap.js:63)
at Object.liveLoad (C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bootstrap.js:50)
at Object. (C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bootstrap.js:79)
at Object. (C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bootstrap.js:81)
at Module._compile (internal/modules/cjs/loader.js:711)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:722)
at Module.load (internal/modules/cjs/loader.js:620)
at tryModuleLoad (internal/modules/cjs/loader.js:559)
at Function.Module._load (internal/modules/cjs/loader.js:551)
at Module.require (internal/modules/cjs/loader.js:658)
Additional information about electron app -
I am using bootstrap for my UI. As per electron faq site, I have the below code in my entry html file
<script>
window.nodeRequire = require;
delete window.require;
delete window.exports;
delete window.module;
</script>
All the modules except electron (index.js - entry point) is imported with
nodeRequire
Analysis done till now -
The javascript logic to connect to database and fetch records are in
separate js file. When I execute the file with 'node file.js', it
works perfectly fine and returns records.
The node version is v9.8.0. Electron version is 3.0.2
I analyzed bootstrap.js file in node_modules\msnodesqlv8\lib\bootstrap.js, line number 63. It traced to below code
var files = require('fs').readdirSync(binaryDir)
I changed that too nodeRequire, but it didnt work.
I have checked similar issues in github but none of the resolutions helped.
UPDATED
I analyzed the bootstrap.js in msnodesqlv8. These are the different error messages
Error while exporting binary Error:
\?\C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bin\sqlserverv8.electron.v2.0.4.ia32.node
is not a valid Win32 application.
\?\C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bin\sqlserverv8.electron.v2.0.4.ia32.node
at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:166:20)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:740)
at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:166:20)
at Module.load (internal/modules/cjs/loader.js:620)
at tryModuleLoad (internal/modules/cjs/loader.js:559)
at Function.Module._load (internal/modules/cjs/loader.js:551)
at Module.require (internal/modules/cjs/loader.js:658)
at require (internal/modules/cjs/helpers.js:20)
at attemptToExportBinary (C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bootstrap.js:58)
at C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bootstrap.js:48
Error while exporting binary Error: The module
'\?\C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bin\sqlserverv8.electron.v2.0.4.x64.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 57. This version of Node.js requires
NODE_MODULE_VERSION 64. Please try re-compiling or re-installing the
module (for instance, using npm rebuild or npm install).
at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:166:20)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:740)
at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:166:20)
at Module.load (internal/modules/cjs/loader.js:620)
at tryModuleLoad (internal/modules/cjs/loader.js:559)
at Function.Module._load (internal/modules/cjs/loader.js:551)
at Module.require (internal/modules/cjs/loader.js:658)
at require (internal/modules/cjs/helpers.js:20)
at attemptToExportBinary (C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bootstrap.js:58)
at C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bootstrap.js:48
Error while exporting binary Error:
\?\C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bin\sqlserverv8.node.v10.8.0.ia32.node
is not a valid Win32 application.
\?\C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bin\sqlserverv8.node.v10.8.0.ia32.node
at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:166:20)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:740)
at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:166:20)
at Module.load (internal/modules/cjs/loader.js:620)
at tryModuleLoad (internal/modules/cjs/loader.js:559)
at Function.Module._load (internal/modules/cjs/loader.js:551)
at Module.require (internal/modules/cjs/loader.js:658)
at require (internal/modules/cjs/helpers.js:20)
at attemptToExportBinary (C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bootstrap.js:58)
at C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bootstrap.js:48
I had raised this issue in github report of msnodesqlv8. The owner updated the version, which resolved the issue. github link - https://github.com/TimelordUK/node-sqlserver-v8/issues/80