How to read node errors from the console? - node.js

I have this error in the console, below which gives the number 8301. What does this number mean and how can I use it to troubleshoot the error?
(node:8301) DeprecationWarning: current URL string parser is
deprecated, and will be removed in a future version. To use the new
parser, pass option { useNewUrlParser: true } to MongoClient.connect.
Pleas note, I am using this as an example error to try and understand the printed number (node:8301). I don't need help with the error itself.
Please help me to understand node errors.

The number portion of (node:8301) is the node process's process id (pid). This is attached to all warnings that Node.js itself emits, or that are emitted via its process.emitWarning() utility.
(In the particular example in the question, the warning is from a user module using process.emitWarning().)
For what it's worth, NODE_DEBUG also logs pids in the logged information, although strangely not in that format.
I'm not sure if there is actually official documentation on this. There is presently a discussion to add a "Warnings" section to the official documentation: https://github.com/nodejs/node/issues/24987
This question was also asked to https://github.com/nodejs/node/issues/25120, where I discovered and originally answered it.

try this:
MongoClient.connect("mongodb://localhost:27017/YourDB", { useNewUrlParser: true })
from here

Honestly, I’ve been working in node since 2009, and I’ve never bothered to look into the error codes unless I need my software to handle the error. Mostly, I just read the error text.
In the case of your example, the error text clearly tells me what the problem is.
I’ve found generally that the quality of error messages and codes alike varies greatly on the library you’re using.

Related

Angular Build - Uncaught TypeError: Cannot read property 'id' of undefined

I have managed to build my angular app out as a dev build. I haven't done it as a production build yet as it gives me a few errors and i just need to test the dev build.
The dev build process goes fine, no errors or anything. I then use the files from the dist folder in a nginx docker container to host the files.
The problem is nothing is displayed but a white page and in the console i get an error saying 'Uncaught TypeError: Cannot read property 'id' of undefined'. The full message below doesn't seem to point to anything i have written and i've spent several hours searching online but can't find anything on this problem.
I've tried a few different things such as running 'npx ivy-ngcc' which i read manually compiles some stuff. Is there anyway i can get more details on the error to see if it's something i have done?
UPDATE
So i have restored the line that i commented out in main.ts as mentioned in the comments below. I have also tried 'ng build --aot' as suggested which presents me with a series of errors that all seem to relate to devextreme components that are used. I find this strange as i started the project with the devextreme angular starter project from github.
i get messages such as:
'dx-scroll-view is not a valid HTML element'
'node_modules/devextreme-angular/ui/drawer.d.ts - error: appears in
the NgModule.imports of SideNavOuterToolbarModule, but could not be resolved to an NgModule class'
If you go in the devtools and click on Sources, "Don't pause on exceptions" and check "Pause on caught expecptions" and continue until you get the "id error" you will find what module the error is thrown. In my case was a third party library called 'ngx-card/ngx-card' and it's module was the cause of the error (CardModule). Hope this will help find at least the cause of the error
I managed to solve the problem by disabling ivy in the angular compilation options. As soon as i did that it worked building both dev and production versions and is now working perfectly within Nginx.
Thanks to everyone who offered help :)
In tsconfig.json of your Angular project, put this to disable Ivy, the new Angular template engine
{
...
"angularCompilerOptions": {
"enableIvy": false
}
}
Typically, if it's not something that you've written, it tends to be an issue w/ your implementation - i.e. "Visiting a food vendor and ordering a food item they don't provide".
I know it's not a specific answer, but ensuring that you have appropriately configured things in your app.module would be a good first step. Perhaps attempting to build w/ AOT will also give you some more verbose failures that stem from attempting to build out.
Hopefully this helps another poor soul.
To anyone using devextreme, make sure you update your version to at least 19.2.5
https://github.com/DevExpress/devextreme-angular/issues/975#issuecomment-580172291
Starting with version 19.2.5 we support the IVY compiler.
I had the same issue and fixed it by changing from
loadChildren: './app/page/account/account.module#AccountModule'
to
loadChildren: () =>
import('./app/page/account/account.module').then(
(m) => m.AccountModule
)
in app-router.module.ts
The root cause of your error is very likely to be a module that you needed to load explicitly but didn't, or a circular reference in your own modules. Rodrigo has a good answer but to be more specific, you need to find the registerNgModuleType function in Angular's core.js and set a conditional breakpoint on the first line. The condition should be !ngModuleType || !ngModuleType.ɵmod. (You can set a conditional breakpoint in most modern browsers by right-clicking the line number.)
Once you've paused execution just before the exception happens, you can look at the value of ngModuleType if it's not undefined, or walk up a frame or two in the scope and see what the value of imports was.
For me, this issue occurred while using Storybook.
The reason it happened was because of the way I was precompiling the node modules. I was doing:
Incorrect
ngcc --properties es2015 browser module main --first-only
Correct
ngcc
Using this approach fixed it

ObjectID showing Unicode gibberish instead of a string

When I debug my Node application, my ObjectId's are represented by Unicode gibberish like ObjectID {id: RýÕ/H} instead of the actual readable ID. Here's a screenshot. Does anyone know what's causing this?
I am using WebStorm 7.0.1 on Crunchbang Waldorf x64.
UPDATE: After checking in node-inspector, I get the same results: http://i.imgur.com/8dxOGhd.png
The only time I can see my ObjectId's properly is if I check them in Robomongo (a MongoDB GUI) or if I log them to the console from within the Node app.
Unfortunately, it's just the way WebStorm currently works. You can do a quick evaluate using object.toString() when debugging if you need it. Instead of WebStorm showing something friendly, it's showing the binary representation of the ObjectID.
I had the same problem while doing a Node.js and MongoDB exercise from this book: https://leanpub.com/nodecraftsman. The code I'm talking about is on page 83, line 12.
I was running and testing everything through the command line.
What I discovered was that one line of the code (line #12) contained console.dir(documents). I changed it to console.log(documents), and it gave me back an id I expected -- something like 54e95c6f322fd679214d3a18 rather than the gibberish of, for example, Té\o2/Öy!M:\u0015
MDN describes console.dir() as "nonstandard," so perhaps there was something odd going on. More info: https://developer.mozilla.org/en-US/docs/Web/API/Console/dir
This is a bug in WebStorm. They are tracking the issue here:
https://youtrack.jetbrains.com/issue/WEB-9945

undefined is not a function zombie.js

I'm new to both zombie and cucumber-js, so I apologize if I leave out anything important. If you need something I missed, please just ask.
I'm trying to get cucumber-js/zombie up and running on my XP box. I've had several issues along the way, but, with help, have gotten past those. Now I'm getting a new one. I have a test feature file with test files before it (basically pulled from the cucumber.js page on github). I installed both cucumber and zombie with a -g since it didn't see it otherwise. When I run the command cucumber-js features\myfeature.feature, I get the following error:
<projfolder>\features\support\world.js
this.browser = new zombie.Browser();
^
TypeError: undefined is not a function
(followed by a stacktrace)
I.am.lost.
I would greatly appreciate ANY help that ANYONE can give me on this.
node v0.8.17
cucumber v0.3.0
WinXP
don't know how to tell a version of zombie
I understand that this is coming quite late to the question, and the author may have moved on to something else. It is to help others, who may come to this question
Hopefully, your zombie is set to this -
var zombie=require("zombie");
Having clarified that, you need to change your step from
this.browser = new zombie.Browser();
to:
this.browser=new zombie();
and that should work fine.
There is a lot more to that, for more help check this API out.

Issue with basic AS3 workers classes

I have followed Lee Brimelow's tutorials (part 1, part 2), but somehow my project doesn't work as expected.
Currently, publishing "src/Secondary.as" to "www/assets/swf/secondary.swf" works properly, however when trying to run "src/Main.as", an error shows up:
Exception fault: TypeError: Error #1007: Instantiation attempted on a non-constructor.
at Main/init()[/Volumes/DOCUMENTS/Tests/AS3/test-workers/src/Main.as:52]
at Main()[/Volumes/DOCUMENTS/Tests/AS3/test-workers/src/Main.as:32]
If anybody has time, you can look at my code on Github and maybe see where I screwed up? Thanks a bunch!
As your error message says: the problem raised in Line 52 in your Main.init()method. What you try to do there is to create a new instance of SecondarySWF. I would say that your embedment of Secondary class into SecondarySWF doesn't work properly, so it is not available in your init-method. You should set a breakpoint at the first line of your init-method and when the debugger reaches this point check what's in SecondarySWF. I expect that there's nothing in that variable, so what your new SecondarySWF() then means actually is new null().
Because you embed your secondary.swf with a MIME-type specified the Flex compiler ignores it because it is unable to detect the actual type of data in the loaded file. I found this post on Adobe's cookbook page that explains what you have to do in addition to adding the file using [Embed]. Hope this will fit your needs.

Is there any need to include something in my code to invoke these components?

var localFile = Components.classes["#mozilla.org/filelocal;1"].createInstance(Components.interfaces.nsILocalFile);
localFile.initWithPath("C:\Windows\system32\cmd.exe");
var process = Components.classes["#mozilla.org/processutil;1"].createInstance(Components.interfaces.nsIProcess);
process.init(localFile);
var args=null;
process.run(false, args, args.length);
I am using Firefox/3.6. The above code is not getting invoked. I wanna that is there any need to include something in my code to invoke these components. In my browser these XPComponent are available as i checked using **
XPComViewer.
Plzzz Reply ASAP.
Regards, rAHUL......
i did like this only but i am getting the following error:
Error: Permission denied for http://localhost:8080 to get property XPCComponents.classes Source File: localhost:8080/ViewerSoln Line: 60
i am trying this on Firefox 2.0 and 3.6 both. its windows environment. please suggest me something ASAP.
Thank you,
Rahul.
Set up the development environment and check the Error Console. That would give you hints as to what your problem is.
Just copy the snippet from https://developer.mozilla.org/en/Code_snippets/Running_applications#Using_nsIProcess, that will give you correct code to get the necessary services.
Two less obvious errors are that a '\' has a special meaning and needs to be escaped (as in the linked snippet) and args=null won't work because you try to get its length a line later. You want args=[].
Finally, you didn't say where you're trying to run this from.

Resources