Tobi example in Node.js - javascript

I am trying to reproduce Tobi test example from the book "Node.js" in Action" the first edition from chapter 10.
I created two files forms.js containing REST api and rendering to-do submit form and first.js. defining Tobi test logic. I launch HTTP server from form.js. When I fire a test in first.js adding to-do task an error happens.
(node:13137) [DEP0025] DeprecationWarning: sys is deprecated. Use util instead.
Here code is:
/home/taras/tobiframework/node_modules/tobi/lib/browser.js:93
this.window = jsdom.jsdom(wrap(html), null, options).createWindow();
^
TypeError: jsdom.jsdom is not a function
at Browser.parse (/home/taras/tobiframework/node_modules/tobi/lib/browser.js:93:23)
at IncomingMessage.<anonymous> (/home/taras/tobiframework/node_modules/tobi/lib/browser.js:280:14)
at IncomingMessage.emit (events.js:202:15)
at endReadableNT (_stream_readable.js:1129:12)
at processTicksAndRejections (internal/process/next_tick.js:76:17)
I expect the output without errors or it is deprecated?

Related

How do I downgrade my ethers.js version from 5.7.2 to 5.6.1?

I'm building an NFT Marketplace demo. Whenever I try to click on 'Create an NFT' button, an Unhandled
Runtime Error pops up -
TypeError: Cannot read properties of undefined (reading 'length').
Call Stack
toUtf8Bytes
node_modules\#ethersproject\strings\lib.esm\utf8.js (176:20)
StringCoder.encode
node_modules\#ethersproject\abi\lib.esm\coders\string.js (12:47)
eval
node_modules\#ethersproject\abi\lib.esm\coders\array.js (49:0)
Array.forEach
<anonymous>
pack
node_modules\#ethersproject\abi\lib.esm\coders\array.js (43:0)
TupleCoder.encode
node_modules\#ethersproject\abi\lib.esm\coders\tuple.js (51:19)
AbiCoder.encode
node_modules\#ethersproject\abi\lib.esm\abi-coder.js (86:0)
Interface._encodeParams
node_modules\#ethersproject\abi\lib.esm\interface.js (253:0)
Interface.encodeFunctionData
node_modules\#ethersproject\abi\lib.esm\interface.js (295:0)
eval
node_modules\#ethersproject\contracts\lib.esm\index.js (125:0)
Generator.next
<anonymous>
fulfilled
node_modules\#ethersproject\contracts\lib.esm\index.js (5:42)
`
I tried to resolve it by two methods suggested online -
Make changes to Infura 'projectId' and 'projectSecret' in .env file and change the 'createitem' function in 'create-nft.js' as well.
Downgrade the ethers.js from current version to 5.6.1, as all the later versions cause problems with Hardhat. But I don't how to downgrade ethers.js and can't find a link where it is stated clearly how to do it.

Cube.js Playground: Error while loading DB schema

I am currently learning Javascript/HTML/CSS in order to build some data dashboard.
I have found this tutorial https://d3-dashboard.cube.dev/setting-up-a-database-and-cube-js
Currently I am getting stuck at this part:
The next step is to create a Cube.js data schema.
When opening the Cube.js playground at: http://localhost:4000, I get the following output in my terminal:
🦅 Dev environment available at http://localhost:4000, I get the following error:
🚀 Cube.js server (0.21.1) is listening on 4000
Error: getaddrinfo ENOTFOUND <YOUR_DB_HOST_HERE>
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:66:26)
And in the Cube.js playground webpage view:
Error while loading DB schema
Error: getaddrinfo ENOTFOUND <YOUR_DB_HOST_HERE> at
GetAddrInfoReqWrap.onlookup [as oncomplete](dns.js66:26)
I have edited the following file:
d3-dashboard/node_modules/#cubejs-backend/server-core/core/index.js
, with:
const checkEnvForPlaceholders = () => {
const placeholderSubstr = '<YOUR_DB_';
const credentials = [
'CUBEJS_API_SECRET=SECRET',
'CUBEJS_DB_TYPE=postgres',
'CUBEJS_DB_NAME=ecom',
'CUBEJS_WEB_SOCKETS=true'
/*'CUBEJS_DB_HOST',*/
/*'CUBEJS_DB_NAME',*/
/*'CUBEJS_DB_USER',*/
/*'CUBEJS_DB_PASS'*/
];
Any input on what I am doing wrong here?
I am totally new to apps and front-ends, so it might be something "stupid" that I am sking, but I really would like to learn from my mistakes :)
Thank you for your time and potential inputs/help!
Have a great day :)
You definitely should not edit any files in the node_modules directory. You should store the env variables in the .env file.
-your-cubejs-server-root
--schema
--.env
--//..
And it may look like
CUBEJS_DB_HOST=localhost
CUBEJS_DB_NAME=cubejs
CUBEJS_DB_USER=root
CUBEJS_DB_PASS=
CUBEJS_DB_TYPE=mysql
CUBEJS_API_SECRET=secret
The error you're getting is saying that the connection to the DB cannot be established. Because you're missing the proper CUBEJS_DB_HOST= variable.
The minimum required set of variables differs for each database and can be found here https://cube.dev/docs/connecting-to-the-database

Node js readline keep evaluating the input and returning a error

I'm running on a strange behavior from Node js readline module while running node on Linux terminal. The module does work but it also try to evaluate the user input as if it was a statement, returning a Reference Error. This is just a simple test I making, but can't get it to work... and I tried many tutorials already. Heres my code:
'nodeReadlineTeste':function(){
var readline = require('readline');
//without terminal:false I was getting double lettering on terminal input...
var rl = readline.createInterface({input:process.stdin,output:process.stdout,terminal:false});
rl.question('What is your name? ',function(resp){getIt(resp)});
//this function is to bypass NODE assyncronous nature... I was getting the log before even answering.
function getIt (resp){console.log(resp); rl.close()};
},
//When running this method and responding my name I get this result:
> global.nodeReadlineTeste()
What is your name? undefined
> Daniel
ReferenceError: Daniel is not defined
at repl:1:1
at ContextifyScript.Script.runInThisContext (vm.js:44:33)
at REPLServer.defaultEval (repl.js:239:29)
at bound (domain.js:301:14)
at REPLServer.runBound [as eval] (domain.js:314:12)
at REPLServer.onLine (repl.js:440:10)
at emitOne (events.js:120:20)
at REPLServer.emit (events.js:210:7)
at REPLServer.Interface._onLine (readline.js:279:10)
at REPLServer.Interface._line (readline.js:626:8)
> Daniel
Wasn't readline supposed to avoid exactly that? Maybe I doing some simple mistake, if so please help me find it. Thank you in advance.
You are trying to run this code in REPL.
Save this code into separate <your_file_name>.js and run
node <your_file_name>.js
The problem is that you are trying run this code in REPL and when you are typing Daniel in next line node trying to find variable with name Daniel.

Unhandled rejection TypeError: this.emitter.refreshFiles is not a function

Im currently testing my angular app, it's using angular (1.5) + typescript(^1.8.0) + karma (^0.13.14);
I've got the following error when trying to run karma:
"Unhandled rejection TypeError: this.emitter.refreshFiles is not a
function
at Plugin.notifyKarmaAboutChanges (/Users/roamer/Documents/work/project/asbhub/develop/asbhub-frontend/node_modules/karma-webpack-with-fast-source-maps/index.js:148:15)
at Plugin. (/Users/roamer/Documents/work/project/asbhub/develop/asbhub-frontend/node_modules/karma-webpack-with-fast-source-maps/index.js:104:9)
at Compiler.applyPlugins (/Users/roamer/Documents/work/project/asbhub/develop/asbhub-frontend/node_modules/webpack/node_modules/tapable/lib/Tapable.js:25:14)
at Watching._done (/Users/roamer/Documents/work/project/asbhub/develop/asbhub-frontend/node_modules/webpack/lib/Compiler.js:93:17)
at Watching. (/Users/roamer/Documents/work/project/asbhub/develop/asbhub-frontend/node_modules/webpack/lib/Compiler.js:76:18)
at Compiler.emitRecords (/Users/roamer/Documents/work/project/asbhub/develop/asbhub-frontend/node_modules/webpack/lib/Compiler.js:319:37)
at Watching. (/Users/roamer/Documents/work/project/asbhub/develop/asbhub-frontend/node_modules/webpack/lib/Compiler.js:59:19)
at /Users/roamer/Documents/work/project/asbhub/develop/asbhub-frontend/node_modules/webpack/lib/Compiler.js:312:11
at Compiler.applyPluginsAsync (/Users/roamer/Documents/work/project/asbhub/develop/asbhub-frontend/node_modules/webpack/node_modules/tapable/lib/Tapable.js:73:70)
at Compiler.afterEmit (/Users/roamer/Documents/work/project/asbhub/develop/asbhub-frontend/node_modules/webpack/lib/Compiler.js:309:8)
at Compiler. (/Users/roamer/Documents/work/project/asbhub/develop/asbhub-frontend/node_modules/webpack/lib/Compiler.js:304:14)
at /Users/roamer/Documents/work/project/asbhub/develop/asbhub-frontend/node_modules/webpack/node_modules/async/lib/async.js:52:16
at Object.async.forEachOf.async.eachOf (/Users/roamer/Documents/work/project/asbhub/develop/asbhub-frontend/node_modules/webpack/node_modules/async/lib/async.js:236:30)
at Object.async.forEach.async.each (/Users/roamer/Documents/work/project/asbhub/develop/asbhub-frontend/node_modules/webpack/node_modules/async/lib/async.js:209:22)
at Compiler.emitFiles (/Users/roamer/Documents/work/project/asbhub/develop/asbhub-frontend/node_modules/webpack/lib/Compiler.js:272:20)
at MemoryFileSystem.(anonymous function) [as mkdirp] (/Users/roamer/Documents/work/project/asbhub/develop/asbhub-frontend/node_modules/karma-webpack-with-fast-source-maps/node_modules/webpack-dev-middleware/node_modules/memory-fs/lib/MemoryFileSystem.js:283:10)"
So I can only restart karma to run my test again instead of letting karma to auto refresh for me. Can't find similar issue on stackoverflow, so I post my issue here. Any suggestions?

Sencha touch production build errors

Using touch 2.1.0 and Cmd 3.1.2.342
Whilst trying to create a production version of my sencha app, I get the following error:
[WRN] C1003: Unsupported Ext.define syntax -- C:\wamp\www\touch-2.1.0\axis\nativ
e\appname\touch\src\fx\TimingFunctions.js:109
[ERR] C2008: Requirement had no matching files (Ext.fx.TimingFunctions) -- C:\wa
mp\www\touch-2.1.0\axis\native\appname\touch\src\fx\Abstract.js:959
[ERR] The following error occurred while executing this line:
C:\wamp\www\touch-2.1.0\axis\native\appname.sencha\app\build-impl.xml:165:
It seems to me that it is saying a file called fx/TimingFunctions.js is required by fx/Abstract.js but cannot be found. However, this can't be what it means as the file exists in that folder.
The command I am using is:
sencha app build production
Line 109 of TimingFunctions.js looks like this:
Ext.define('Ext.fx.TimingFunctions', Ext.apply({
singleton: true,...
One solution is to change line 109 of TimingFunctions.js from:
Ext.define('Ext.fx.TimingFunctions', Ext.apply({
to:
Ext.define('Ext.fx.TimingFunctions', {
and change line 136 of the same file from:
}, EasingPrototype));
to:
}, EasingPrototype);
This then allows the build to go ahead.
However, when I then view the production app in the web browser, it freezes and I get the following error
Uncaught TypeError: Object # has no method 'call' process sencha-touch-all-debug.js:6767
(anonymous function) process sencha-touch-all-debug.js:6774
(anonymous function) sencha-touch-all-debug.js:6779
Ext.apply.onBeforeCreated sencha-touch-all-debug.js:5196
process sencha-touch-all-debug.js:5262
process sencha-touch-all-debug.js:5268
process sencha-touch-all-debug.js:5268
process sencha-touch-all-debug.js:5268
Ext.apply.process sencha-touch-all-debug.js:5272
Ext.Class.ExtClass sencha-touch-all-debug.js:5183
Ext.ClassManager.create sencha-touch-all-debug.js:6725
Ext.apply.define sencha-touch-all-debug.js:7407
(anonymous function) TimingFunctions.js?_dc=1379403994382:109
(anonymous function) TimingFunctions.js?_dc=1379403994382:138
There was a spelling mistake in the files fx/Abstract.js and fx/TimingFunctions.js
Actually, it's not a spelling mistake - more like a grammatical error.
Abstract.js calls a function in TimingFunctions.js. in Abstract.js it is referred to as EasingMap, where as in TimingFunctions.js it is called easingMap

Categories