TypeError: Cannot read property 'name' of undefined [tensorflowjs] - node.js

I get an error in tf.model when convert model from tensorflow2 to tensorflow js
That line get error:
model = tf.model({inputs: img, outputs: [a, b]})
My error:
/home/whoisltd/works/mtcnn-tfjs/node_modules/#tensorflow/tfjs-layers/dist/tf-layers.node.js:30023
finally { if (e_3) throw e_3.error; }
^
TypeError: Cannot read property 'name' of undefined
at LayersModel.Container [as constructor] (/home/whoisltd/works/mtcnn-tfjs/node_modules/#tensorflow/tfjs-layers/dist/tf-layers.node.js:30015:46)
at new LayersModel (/home/whoisltd/works/mtcnn-tfjs/node_modules/#tensorflow/tfjs-layers/dist/tf-layers.node.js:32802:28)
at Object.model (/home/whoisltd/works/mtcnn-tfjs/node_modules/#tensorflow/tfjs-layers/dist/tf-layers.node.js:35296:12)
at PNet (/home/whoisltd/works/mtcnn-tfjs/models.js:39:16)
at new MTCNN (/home/whoisltd/works/mtcnn-tfjs/mtcnn.js:16:21)
at image_demo (/home/whoisltd/works/mtcnn-tfjs/demo.js:11:13)
at Object.<anonymous> (/home/whoisltd/works/mtcnn-tfjs/demo.js:38:1)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
Do you know how to fix this?

Related

Typescript Type Annotations throws 'Unexpected token ":"'

I am trying to annotate my variables with types but when running the code it simply gives off an error:
let foo: number = 23;
console.log( foo );
// let foo: number = 23;
^
// SyntaxError: Unexpected token ':'
// [90m at Object.compileFunction (node:vm:352:18)[39m
// [90m at wrapSafe (node:internal/modules/cjs/loader:1031:15)[39m
// [90m at Module._compile (node:internal/modules/cjs/loader:1065:27)[39m
// [90m at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)[39m
// [90m at Module.load (node:internal/modules/cjs/loader:981:32)[39m
// [90m at Function.Module._load (node:internal/modules/cjs/loader:822:12)[39m
// [90m at Function.executeUserEntryPoint [as runMain] // (node:internal/modules/run_main:79:12)[39m
// [90m at node:internal/main/run_main_module:17:47[39m
You have two options:
First compile it to plain JS with tsc myfile.ts and run the JS file with node myfile.js.
Or npm install ts-node which lets you run TS files like you would run JS files: ts-node myfile.ts

The "amdefine" can not load a custom module

I installed the requirejs package to optimize the work with paths to files. In general, I do the next steps:
I have an object with paths to file, that have next values:
"app/database": "/home/dmitry/projects/information-platform-api/app/utils/database"
After I initialize the requirejs mapping in app.js (main file):
requirejs.config({
baseUrl: __dirname,
nodeRequire: require,
paths: paths,
map: {
'*': paths
}
});
After, I need to initialize base models, and with help for I called all files from paths object. This looks like:
for (let file in paths) {
requirejs(paths[file]);
}
When I initializing the file, which has the dependency of the above "app/database", I have a message error: Error: Cannot find module 'app/database'.
Maybe, I don't understand "How works the amdefine", but I have opinion, what a requirejs and amdefine don`t link. Do you have any ideas, why it doesn't work?
A part of the file, which need to investigate:
if (typeof define !== 'function') {
var define = require('amdefine')(module);
}
define([
'sequelize',
'app/database',
'model/student'
], (
Sequelize,
sequelize,
Student
) => { });
Result of my investigation:
The amdefine doesn't know about requirejs mapping.
Full error message:
Error: Tried loading "/home/dmitry/projects/information-platform-api/app/code/IndividualScheduling/model/entity/Company" at /home/dmitry/projects/information-platform-api/app/code/IndividualScheduling/model/entity/Company then tried node's require("/home/dmitry/projects/information-platform-api/app/code/IndividualScheduling/model/entity/Company") and it failed with error: Error: Cannot find module 'app/database'
Require stack:
- /home/dmitry/projects/information-platform-api/app/code/IndividualScheduling/model/entity/Company.js
- /home/dmitry/projects/information-platform-api/app.js
- /home/dmitry/projects/information-platform-api/bin/www
at /home/dmitry/projects/information-platform-api/node_modules/requirejs/bin/r.js:2600:27
at Object.execCb (/home/dmitry/projects/information-platform-api/node_modules/requirejs/bin/r.js:1946:33)
at Module.check (/home/dmitry/projects/information-platform-api/node_modules/requirejs/bin/r.js:1133:51)
at Module.enable (/home/dmitry/projects/information-platform-api/node_modules/requirejs/bin/r.js:1426:22)
at Object.enable (/home/dmitry/projects/information-platform-api/node_modules/requirejs/bin/r.js:1807:39)
at Function.req.get (/home/dmitry/projects/information-platform-api/node_modules/requirejs/bin/r.js:2524:33)
at Object.localRequire [as require] (/home/dmitry/projects/information-platform-api/node_modules/requirejs/bin/r.js:1678:40)
at requirejs (/home/dmitry/projects/information-platform-api/node_modules/requirejs/bin/r.js:2047:24)
at Object.<anonymous> (/home/dmitry/projects/information-platform-api/app.js:142:5)
at Module._compile (internal/modules/cjs/loader.js:1156:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14)
at Module.require (internal/modules/cjs/loader.js:1042:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous> (/home/dmitry/projects/information-platform-api/bin/www:7:13)
at Module._compile (internal/modules/cjs/loader.js:1156:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
at internal/main/run_main_module.js:18:47 {
originalError: Error: Cannot find module 'app/database'
Require stack:
- /home/dmitry/projects/information-platform-api/app/code/IndividualScheduling/model/entity/Company.js
- /home/dmitry/projects/information-platform-api/app.js
- /home/dmitry/projects/information-platform-api/bin/www
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:980:15)
at Function.Module._load (internal/modules/cjs/loader.js:862:27)
at Module.require (internal/modules/cjs/loader.js:1042:19)
at req (/home/dmitry/projects/information-platform-api/node_modules/amdefine/amdefine.js:144:31)
at stringRequire (/home/dmitry/projects/information-platform-api/node_modules/amdefine/amdefine.js:220:28)
at amdRequire (/home/dmitry/projects/information-platform-api/node_modules/amdefine/amdefine.js:113:24)
at /home/dmitry/projects/information-platform-api/node_modules/amdefine/amdefine.js:177:24
at Array.map (<anonymous>)
at runFactory (/home/dmitry/projects/information-platform-api/node_modules/amdefine/amdefine.js:176:25)
at define (/home/dmitry/projects/information-platform-api/node_modules/amdefine/amdefine.js:277:13)
at Object.<anonymous> (/home/dmitry/projects/information-platform-api/app/code/IndividualScheduling/model/entity/Company.js:5:1)
at Module._compile (internal/modules/cjs/loader.js:1156:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14)
at Module.require (internal/modules/cjs/loader.js:1042:19)
at require (internal/modules/cjs/helpers.js:77:18)
at /home/dmitry/projects/information-platform-api/node_modules/requirejs/bin/r.js:2598:75
at Object.execCb (/home/dmitry/projects/information-platform-api/node_modules/requirejs/bin/r.js:1946:33)
at Module.check (/home/dmitry/projects/information-platform-api/node_modules/requirejs/bin/r.js:1133:51)
at Module.enable (/home/dmitry/projects/information-platform-api/node_modules/requirejs/bin/r.js:1426:22)
at Object.enable (/home/dmitry/projects/information-platform-api/node_modules/requirejs/bin/r.js:1807:39) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/home/dmitry/projects/information-platform-api/app/code/IndividualScheduling/model/entity/Company.js',
'/home/dmitry/projects/information-platform-api/app.js',
'/home/dmitry/projects/information-platform-api/bin/www'
]
},
moduleName: '/home/dmitry/projects/information-platform-api/app/code/IndividualScheduling/model/entity/Company',
requireModules: [
'/home/dmitry/projects/information-platform-api/app/code/IndividualScheduling/model/entity/Company'
]
}
Process finished with exit code 1
The solution is here guys. The amdefine have two params, first param it's a global variable module, and the second it's require function for calling the local files. By default, it was just require not requirejs which contains custom mapping.
if (typeof define !== 'function') {
var define = require('amdefine')(module, require('requirejs'));
}

installing with NPM gives out error:2406C06E:random number generator

I'm using Ubuntu server 18.04.
Every time I try to use NPM it crashes and shows the following exception:
internal/crypto/random.js:119
if (ex) throw ex;
^
Error: error:2406C06E:random number generator:RAND_DRBG_instantiate:error retrieving entropy
at Object.randomBytes (internal/crypto/random.js:54:31)
at /usr/lib/node_modules/npm/lib/npm.js:444:32
at Object.<anonymous> (/usr/lib/node_modules/npm/lib/npm.js:496:3)
at Module._compile (internal/modules/cjs/loader.js:959:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
at Module.load (internal/modules/cjs/loader.js:815:32)
at Function.Module._load (internal/modules/cjs/loader.js:727:14)
at Module.require (internal/modules/cjs/loader.js:852:19)
at require (internal/modules/cjs/helpers.js:74:18)
at /usr/lib/node_modules/npm/bin/npm-cli.js:28:13 {
opensslErrorStack: [
'error:2406B072:random number generator:RAND_DRBG_generate:in error state',
'error:2406C06E:random number generator:RAND_DRBG_instantiate:error retrieving entropy',
'error:2406B072:random number generator:RAND_DRBG_generate:in error state',
'error:2406C06E:random number generator:RAND_DRBG_instantiate:error retrieving entropy'
]
}
Does anybody has any idea of what could be wrong?

TypeError: Wrong input type "String" for args

I'm trying to create a connection between nodejs and redisql i fall into problem when creating table something called TypeError: Wrong input type "String" for args
the stacktrace will be added at the end of post, i have added
const redisql = require('redisql');
const sqlClient = redisql.createClient();
sqlClient.create_table("employee", " id int , name TEXT , salary double ", redisql.print);
once i run the third command i get this stack trace
TypeError: Wrong input type "String" for args
at RedisClient.send_command.RedisClient.sendCommand (d:\BuildProjects\redisproject\node_modules\redis\lib\extendedApi.js:27:19)
at rsql_send_command (d:\BuildProjects\redisproject\node_modules\redisql\index.js:28:22)
at RedisClient.proto.CREATE_TABLE (d:\BuildProjects\redisproject\node_modules\redisql\index.js:47:5)
at new Cache (d:\BuildProjects\redisproject\app\index.js:11:15)
at Object.<anonymous> (d:\BuildProjects\redisproject\app\index.js:45:20)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (d:\BuildProjects\redisproject\index.js:1:77)
at Module._compile (module.js:649:14)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
Waiting for the debugger to disconnect...
TypeError: Wrong input type "String" for args
extendedApi.js:27
at RedisClient.send_command.RedisClient.sendCommand (d:\BuildProjects\redisproject\node_modules\redis\lib\extendedApi.js:27:19)
at rsql_send_command (d:\BuildProjects\redisproject\node_modules\redisql\index.js:28:22)
a
i followed this project link in order to build mine
have no idea why, i read deeply the code and it seems it should be okay. could someone help me ?

Extra info displayed in uncaught error vs caught Error object

If I run an erroneous file node err.js
console.log(hi);
it throws the error, which if uncaught shows this: (note the first two lines)
C:\test\err.js:2
console.log(hi);
^
ReferenceError: hi is not defined
at Object.<anonymous> (C:\test\err.js:2:17)
at Module._compile (module.js:426:26)
at Object.Module._extensions..js (module.js:444:10)
But if I try-catch the error and display the Error object:
try {
console.log(hi);
} catch (err) {
console.error(err);
console.error(err.message);
console.error(err.stack);
}
[ReferenceError: hi is not defined]
hi is not defined
ReferenceError: hi is not defined
at Object.<anonymous> (C:\test\err.js:2:17)
at Module._compile (module.js:426:26)
at Object.Module._extensions..js (module.js:444:10)
at Module.load (module.js:351:32)
at Function.Module._load (module.js:306:12)
at Function.Module.runMain (module.js:467:10)
at startup (node.js:117:18)
at node.js:948:3
Where does this part go:
C:\test\err.js:2
console.log(hi);
^
How can I retrieve this piece of info from the Error object?

Resources