node-inspector looking for <module>.js when 'require'd - javascript

I am getting started with Node Inspector (Linux Mint 14). When I try to debug a simple .js file - console.log("Hello World") - with:
node-debug app.js
Node Inspector starts as expected, breaks on the first line and runs to completion on 'resume'.
However if I include a 'require' in my app.js:
require('someModule');
console.log('Hello World);
NI breaks ok, but when I 'resume' it throws a 'file not found' error as it can't find a .js file with the node module name in node_modules, i.e. ./node_modules/someModule.js. Although there is a ./node_modules/someModule/someModule.js.
Can anyone see what I'm missing?

Doh! Whilst I was clicking around I'd clicked on the "pause on all exceptions" button in the bottom left corner. Clicked on this again and it's now ignoring all the exceptions thrown as it looks for the module files.

Related

facing windows script host error whenever i create and start a .js file

This error is showing for me whenever I create a new .js file example: teams.js
this is the error that appears :
Script: C:\**\**\Desktop\foot\teams.js Line: 1 Charact : 1 Error: Syntax error Code: 800A03EA Source: Microsoft JScript compilation error
Everything was normal and working perfectly.
As usual, I turned off my pc and the error appeared the next day.
On the first day, the error was saying that **windows do not have the appropriate authorization for accessing file /path **
I looked for it on the internet, and I found a solution that says to uninstall adobe Flashplayer and reinstall it, I did so but the error remains.

Debug a node.js process forked via child_process.fork in VSCode

I'm trying to debug a Node script forked using child_process's fork method using VSCode.
I have read almost all of the related docs, discussions but without any success. I'm not sure what am I doing wrong.
For your reference, I have posted a my sample code as a gist and is available at: https://gist.github.com/dpnishant/43096af3fecde4ec9fdea7c1d81cf543
It contains the three files: parent.js, child.js and launch.json (vscode configuration). I'm trying to setup 2 breakpoints: one at https://gist.github.com/dpnishant/43096af3fecde4ec9fdea7c1d81cf543#file-child-js-L4 and another at https://gist.github.com/dpnishant/43096af3fecde4ec9fdea7c1d81cf543#file-parent-js-L16.
Case-1
When I click "Start Debugging" using the "Launch Program" config, I'm able to hit the line 16 breakpoint on parent.js but the other breakpoint in child.js is never hit.
Case-2
When I click "Start Debugging" using the "Attach" config, I get the following error:
Debugging with legacy protocol because Node.js version could not be determined (Error: connect ECONNREFUSED 127.0.0.1:9999)
Case-3
When I start node parent.js in Terminal and immediately switch to VSCode to click "Start Debugging" using the "Attach to Process" config and choose the node process with the "child.js" script, I'm able to hit breakpoint on line 4 in child.js but by that time, the loop has already started and it's already late.
So my requirement is a method through which I can start my parent.js script and hit the desired breakpoint in child.js as soon as it starts execution.
Can someone point out to me where am I doing wrong? And what would be a optimum solution for my use-case?

node js returning Syntax error: Unexpected identifier

I downloaded and installed node.js on Windows and I'm following a simple tutorial from nodebeginner.org.
I've created a file called HelloWorld.js which contains just:
console.log("Hello World");
When I type node HelloWorld.js in the node.js console I get:
SyntaxError: Unexpected identifier
I checked my classpath variable and it has the C:\Program Files\nodejs\ on it.
HelloWorld.js is still open in Notepad++ for editing.
What am I doing wrong?
I think you are already in the the console.
Just follow the steps to fix the error:
1) Try doing CTRL + C couple of times. See if you exit the console
2) Then do node HelloWorld.js
I think you will get your output
When in your node console already, you can simply do require("./HelloWorld.js") to get the output. (Given that you are in the directory that contains this file)
When I type node HelloWorld.js in the node.js console I get
You should type JavaScript into the Node.js console.
node is a program name. HelloWorld.js is a command line argument. They are not JavaScript.
You should type those into your shell (e.g. Windows Powershell or bash).
I had the same issue when following an online course, my mistake was that i did not safe the file i was following as .js in the name when saving.
Therefore my Hello.js did not open because it was only Hello
If people are facing below-mentioned error: Uncaught SyntaxError: Unexpected identifier at the time of running, console.log("Hello World"); code with command, node HelloWorld.js, in VS code editor
Problem :
node HelloWorld.js ^^^^^ Uncaught SyntaxError: Unexpected identifier
Solution :
(1) Just install Babel JavaScript extension in VS code editor
(2) After Babel JavaScript extension is installed, save your Program and then run your program with the command, node HelloWorld.js
Definitely will get the expected result.
I'm on linux and I'd the same issue
what I was writing in terminal is :
node
node file.js
all what I had to do is to write node file.js from the start without writing node first .
Although the question is old, I just solved it. So for anyone who still likes an answer: Apparently Node.Js installs two different consoles or executables. There is "Node.js" and there is "Node.js command prompt". Use the latter and it will work
To clarify, I used another tutorial in Dutch. Use the Javascript code in there and then in your web browser type http://localhost:3000. There you will see the Hello World output.
A little late but I figured this out as I'm learning it as well. You are not in the correct Node.js command window:
You are probably trying to run Node.js, ie. the one with the red arrow. This gives you the "Unexpected identifier" error. You want the Node.js command prompt, or the one shown with a green arrow.
Craig
On windows hit CTRL + D to exit REPL and then run HelloWorld.js again

Eclipse Node Debugger require() exception

I am using windows machine with the latest eclipse.
I followed the instructions over https://github.com/nodejs/node-v0.x-archive/wiki/Using-Eclipse-as-Node-Applications-Debugger.
On the command line I execute node --debug-brk server.js. When I run eclipse debugger, it connects to the node. The first line in my code is require(), and when the debugger visits this line, it throws an exception:
line 1: uncaught JavaScript runtime exception: ReferenceError: "require" is not defined.
I tried to have a breakpoint after that line, but whenever the debugger starts, it visits the first (require()) line.
How can I pass this line, and continue debugging?
quote from https://github.com/joyent/node/wiki/Using-Eclipse-as-Node-Applications-Debugger
Note that V8 engine debugger is not behaving very good when it steps over or steps into >require() method (it will crash), so try to set up first breakpoint past the initial module >loading. This will also enable you to set breakpoints in any of those modules as well.
try
node --debug server.js

IE8 - window.open() - "No such interface supported"

When I call window.open() from JavaScript, I get the error dialog with the message "Line: xxx Error: No such interface supported"
Google leads me to websites referring as far back as IE4 saying that I need to run regsrvr32 on several DLLs.
Is there a better solution?
EDIT: exact code requested
<html><head>
<script type="text/javascript">
function windowOpen() {
window.open("http://localhost/mysite/mypage.asp", "myWindowName", "");
}
</script></head>
<body>
<button onclick="windowOpen();return false;">Hi There</button>
</body></html>
EDIT2:
The provided answers all go back to IE4/Win95 days. I mean, seriously?? Regardless, I disabled Smooth scrolling in IE8 (!!!) and also attempted to register the controls listed in the kb article mentioned by Shoban, but got an error attempting to register shdocvw.dll (The module "shdocvw.dll" was loaded but the entry-point DllRegisterServer was not found. Make sure that "shdocvw.dll" is a valid DLL or OCX file and then try again.)
First of all, try just the following and see if the problem goes away:
OPTION 1
Step 1: Fix IE
Copy and paste the following in the command prompt running as an admin, then press :
"%systemroot%\system32\regsvr32.exe" "C:\Program Files\Internet Explorer\ieproxy.dll"
If you are running 64 bit windows, try this:
"%systemroot%\system32\regsvr32.exe" "C:\Program Files> (x86)\Internet Explorer\ieproxy.dll"
OPTION 2
If the above doesn't work, try the following two steps.
Step 1: Re-register all DLLs
Open a command prompt as an admin. Type the following command:
FOR /R C:\ %G IN (*.dll) DO "%systemroot%\system32\regsvr32.exe" /s "%G"
You will probably get some error windows popping up at this point, just ignore them all and close them when the command prompt stops churning.
Step 2: Fix IE
Copy and paste the following in the command prompt running as an admin, then press :
"%systemroot%\system32\regsvr32.exe" "C:\Program Files\Internet Explorer\ieproxy.dll"
If you are running 64 bit windows, try this:
"%systemroot%\system32\regsvr32.exe" "C:\Program Files> (x86)\Internet Explorer\ieproxy.dll"
Sources:
http://social.technet.microsoft.com/Forums/en-US/w7itproui/thread/99e4ab4f-165d-4691-90dd-ab41a05d26a2
http://forums.techguy.org/all-other-software/568737-solved-internet-explorer-wont-start.html
Check if there are any toolbar installed. I had the same problem and this caused because I run fiddler http debugging proxy
On Win10 x64 with IE11 this solved my problem:
regsvr32 "C:\Windows\SysWOW64\ieproxy.dll"

Categories