Error: Dynamic Linking Error: Win32 error 193 while binding to Eztwain3.dll library using nodejs ffi - node.js

I successfully bound my nodejs to the 'TSCLIB.dll' using the ffi, but when I want to bind it to 'Eztwain3.dll', I always have "Error: Dynamic Linking Error: Win32 error 193".
C:\Users\dev\Desktop\nodeApp>node scan.js
C:\Users\dev\Desktop\nodeApp\node_modules\ffi\lib\dynamic_library.js:74
throw new Error('Dynamic Linking Error: ' + err)
^
Error: Dynamic Linking Error: Win32 error 193
at new DynamicLibrary (C:\Users\dev\Desktop\nodeApp\node_modules\ffi\lib\dynamic_library.js:74:11)
at Object.Library (C:\Users\dev\Desktop\nodeApp\node_modules\ffi\lib\library.js:45:12)
at Object.<anonymous> (C:\Users\dev\Desktop\nodeApp\scan.js:17:24)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Function.Module.runMain (module.js:694:10)
at startup (bootstrap_node.js:204:16)
The execution shown above appear when I'm trying to run this script.
const ffi = require('ffi');
const ref = require('ref');
const platform = process.platform;
var lib = null;
if (platform === 'win32') {
lib = 'Eztwain3.dll';
} else {
throw new Error('unsupported plateform for lib')
}
var instance = ffi.Library(lib, {
});
https://imgur.com/a/F4rzZDT
https://imgur.com/a/rminDnN
I tried to execute the same script with 'TSCLIB.dll' and it run without exeption.
So, how can I call the 'Eztwain3.dll' library with node ffi?

I resolve my problem by changing the nodejs from 64bit to 32bit because my dll is 32 bit

Encountered the same issue.
Use sigcheck to find that the dll is 32bit, while node is 64bit version.
There're two solutions:
Replace 32bit dll with 64bit one, if you can get one.
Replace node 64bit with 32bit one.

Related

googleapis-common throwing error in UUID dependency

I'm trying to get a very basic oauth example to work in a node.js app with express and googleapis. Upon running the application it throws a TypeError inside the UUID dependency which is included with the googleapis-common module. I'm getting a bit frustrated at this point because I have not been able to find any additional information about this to allow me to resolve it myself.
Take a look at the screenshot below for the specifics:
Here it is in text if that makes things easier:
Exception has occurred: TypeError: Cannot assign to read only property 'name' of function 'function generateUUID(value, namespace, buf, offset) {
if (typeof value === 'string') {
value = strin...<omitted>... }'
at _default (C:\Users\ficar\OneDrive\Desktop\Frontend\node_modules\googleapis-common\node_modules\uuid\dist\v35.js:71:23)
at Object.<anonymous> (C:\Users\ficar\OneDrive\Desktop\Frontend\node_modules\googleapis-common\node_modules\uuid\dist\v3.js:14:27)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (C:\Users\ficar\OneDrive\Desktop\Frontend\node_modules\googleapis-common\node_modules\uuid\dist\index.js:63:34)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
The file this is being thrown in is called "v35.js".
My initial thought is that I must be missing some additional library that interprets the logic throwing the error differently. Eager to learn more about this and find a resolution.
Looks like this is how the uuid module works
node_modules/uuid/dist/v35.js
function _default(name, version, hashfunc) {
function generateUUID(value, namespace, buf, offset) {
...
} // Function#name is not settable on some platforms (#270)
try {
generateUUID.name = name; // eslint-disable-next-line no-empty
} catch (err) {} // For CommonJS default export support
...
Authors warn (comment on line 4), that name property may not be settable and bypass it with empty catch

Angular giving Syntax Error during initial configuration

I am trying to create an Angular application on a Windows 10 OS. Previously when I attempted to install Node.js and NPM I was getting 'Cannot find 'resolve' of undefined'. I solved it by downgrading my Node.js to 6.17 and the NPM to 3.10. I can now download the Angular CLI but when I use the 'new' command, I get the following error.
C:\Users\user_name\AppData\Roaming\npm\node_modules\#angular\cli\bin\ng:23
);
^
SyntaxError: Unexpected token )
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.runMain (module.js:611:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:160:9)
When I open the file location I get the following:
#!/usr/bin/env node
'use strict';
// Provide a title to the process in `ps`.
// Due to an obscure Mac bug, do not start this title with any symbol.
try {
process.title = 'ng ' + Array.from(process.argv).slice(2).join(' ');
} catch (_) {
// If an error happened above, use the most basic title.
process.title = 'ng';
}
// This node version check ensures that extremely old versions of node are not used.
// These may not support ES2015 features such as const/let/async/await/etc.
// These would then crash with a hard to diagnose error message.
// tslint:disable-next-line: no-var-keyword
var version = process.versions.node.split('.').map(part => Number(part));
if (version[0] < 10 || version[0] === 11 || (version[0] === 10 && version[1] < 13)) {
process.stderr.write(
'Node.js version ' + process.version + ' detected.\n' +
'The Angular CLI requires a minimum Node.js version of either v10.13 or v12.0.\n\n' +
'Please update your Node.js version or visit https://nodejs.org/ for additional instructions.\n',
);
process.exit(3);
}
require('../lib/init');
It's complaining about the parentheses for the if statement. I tried getting rid of the parentheses and it only makes the situation worse. What would be the best way to go about solving this situation. WOuld it be better to use somehow install a new version of Node and work around the 'resolve' error or take with what I have with the version at hand?

Deployment of Node native modules to Azure WebSites,I'm experiencing some problems

I deploy a node application to the Azure website.
The tricky part is that I'm using a node module called "opencv" that needs to be compiled at install time using node-gyp.
I use the node-gyp rebuild --arch=ia32 command to compile it int the windows10. But when I used it in the Azure website, I get following problem:
Wed Apr 26 2017 04:48:35 GMT+0000 (Coordinated Universal Time): Application has thrown an uncaught exception and is terminated:
Error: The specified module could not be found.
\\?\D:\home\site\wwwroot\app\api\lib\opencv.node
at Error (native)
at Object.Module._extensions..node (module.js:434:18)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (D:\home\site\wwwroot\app\api\lib\image_operation.js:5:14)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
This is the code I call:
'use strict';
var fs = require('fs');
var path = require('path');
var opencv = require("./opencv.node");
function isContains(str, substr) {
return new RegExp(substr).test(str);
}
module.exports = {
post: function (imageInfo, data) {
if (isContains(imageInfo.imageName, ".yuv")) {
var imageName = imageInfo.imageName.substr(0, imageInfo.imageName.length - 3) + "jpg";
opencv.yuvToJpeg(path.resolve(__dirname, "../../image/" + imageName), imageInfo.width, imageInfo.height, Array.prototype.slice.call(data, 0));
} else if (isContains(imageInfo.imageName, ".jpg")) {
fs.writeFileSync(path.resolve(__dirname, "../../image/" + imageInfo.imageName), data);
}
return "success";
}
};
But that file is in-fact deployed on the server:
Please help me, and tell me what to do
Its readme says that "You'll need OpenCV 2.3.1 or newer installed before installing node-opencv". And as Azure Web Apps is a Software as a service (SaaS), we don't have the privilege to install arbitrary software there. But if that is a requirement for you, you'll need to use an alternative offering, like Cloud Service or VM.

Gulp-Sourcemaps, SyntaxError: Unexpected token >

Gulp / npm noobie here.
I'm trying to use gulp-sourcemaps, and for some reason, it crashes on var sourcemaps = require('sourcemaps').(It crash only when this line's in the file)
gulpfile:
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var sourcemaps = require('gulp-sourcemaps');
gulp.task('generateApp', function () {
return gulp.src([some paths...])
.pipe(sourcemaps.init())
.pipe(concat('app.min.js'))
.pipe(uglify())
.pipe(sourcemaps.write())
.pipe(gulp.dest(path...));
});
Error :
C:\Projets\node_modules\strip-bom\index.js:2
module.exports = x => {
^
SyntaxError: Unexpected token >
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (C:\Projets\node_modules\gulp-sourcemaps\src\init.js:10:14)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
Has anyone encounter this type of error?
I tried to google it, without any success.
I just started getting the same error and fixed it by replacing the code in C:\Projects\node_modules\strip-bom\index.js with this:
'use strict';
module.exports = function (x) {
if (typeof x !== 'string') {
throw new TypeError('Expected a string, got ' + typeof x);
}
// Catches EFBBBF (UTF-8 BOM) because the buffer-to-string
// conversion translates it to FEFF (UTF-16 BOM)
if (x.charCodeAt(0) === 0xFEFF) {
return x.slice(1);
}
return x;
};
Then, I had to run npm rebuild node-sass to get it to work again. It seems to be an issue with an older version of the Strip-bom node module.
For more info, check this out: https://github.com/sindresorhus/strip-bom/commit/e2a3c3b83706ee5baac284f3862d3f6b9e1564e5
UPDATED ANSWER:
This error is caused by using an older version of Node. The Strip-bom module is now using ES2015 (ES6) syntax which requires Node 5.0+. (See Node's ES2015 support list here)
To test your version of Node, run:
node -v
If it's less than 5.0, you'll need to update it. You can download the newest version of Node here:
https://nodejs.org/en/
After installing the new version of Node, I still needed to run npm rebuild node-sass to get Gulp up and running again.
The former answer will still work if you don't want to update your Node version, however, as Louis pointed out, manually editing node module files is not a best-practice.

TypeScript / NodeJS: variable not defined, using internal ref paths for separate files

I have been testing TypeScript with node, all was going well until i tried splitting these out.
Am I forced to use modules ?
I have 2 files, app.ts which has a reference path to the hellofile.tst
/// <reference path="hellofile.ts" />
var testme = new Hello()
console.log(testme.testMe());
and the hellofile.ts which contains
class Hello {
testMe():string {
return "hello";
}
}
Now running the program (i am using webstorm), I get the following error.
/usr/local/bin/node app.js
/
Users/tst/WebstormProjects/NodeJsWithTypescript/app.js:2
var testme = new Hello();
^
ReferenceError: Hello is not defined
at Object.<anonymous> (/Users/tst/WebstormProjects/NodeJsWithTypescript/app.js:2:18)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
Process finished with exit code 8
You don't have to use modules. You can compile with --out flag
But external modules with commonjs is highly recommended if targeting nodejs : http://m.youtube.com/watch?v=KDrWLMUY0R0

Resources