VS Code Terminal not running - javascript

when I go for console.log("hello world") my vs code terminal is not working unless I switch to java script debug terminal?
any one who know the solution please help

Try this ===>
1 Type node in terminal
2 console.log("Hello World")

Its pretty simple, just 2 clicks away
=> 1. Click on File
=> 2. Click on Auto Save

Option 1: Make sure that you installed Node.js After that, you need to type in Terminal window: node [whateverYourFilenameIs], click entre. //you type the word node, followed by your filename without the square brackets.
Option 2: Make sure you installed Node.js and install the VSCode extension Code Runner, restart VSCode, click on ctrl+Alt+N to run your file in terminal.

It is simple
write some code example: console.log("javascript");
ctrl +s
on terminal node and your js file name ...click enter ....and there will be no error

Related

Can't download a pdf file in npx cypress run --headed mode?

Hope to get some help with what is my first question to the community...
I'm using the Tricentis Sample App to practice some testautomation with Cypress (javascript) and I'm having issues with the final step. (Downloading the mock invoice and checking the presence of it in the downloads folder)
//This function displays the "download pdf" button
function selectPriceOption(cy){
cy.get('#selectplatinum').check({force:true})
}
//this function is supposed to download the pdf
function downloadQuote(cy){
cy.wait(2000)
cy.get('#downloadquote').click()
cy.wait(20000)
}
//This function checks if file exists in the download folder
function checkFileExists(cy){
cy.readFile('C:/xxx/Documents/cypress/downloads/Tricentis_Insurance_Quote.pdf')
}
module.exports = {
enterAutoPage,
enterVehicleData,
enterInsuranceData,
enterProductData,
selectPriceOption,
checkFileExists,
downloadQuote
//sendQuote
}
When I'm running the script on npx cypress open mode, it downloads the pdf generated without a hitch. But as soon as I use npx cypress run --headed it doesn't manage to download the pdf file and as a consequence the test case throws a fail... Btw, I know the cy.wait command is not needed, it was just my last attempt to see if it needed additional waiting time. Still didn't work!
Now, here's what bugs me... If I run the script in open mode first, the download is successful and if I then go for the "run --headed" mode afterwards, it finds the file! I'm running trashAssetsBeforeRuns: false in the config file. So the check file function is working as intended. But when the folder is empty and I only use --headed mode then the download is NOT successful and the test case fails due the file is missing when the script reaches the last test step. I hope this explanation makes sense... #newbietechnicaltester
PS: Leaving the possibility open to something funky going on with the Tricentis site that is causing the code to not work as intended

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

Run JavaScript in a Windows Command Line

This is something I only found out about today is that JavaScript can be run through a windows command line.
So I found out that to run a javascript file in windows cmd.exe you use cscript.
My hworld.js file only has one line
print('hello world');
I try to run this through the command line with
cscript /Prog/hworld.js
It didn't run with the error
Microsoft JScript runtime error: Object Expected
Are there steps i need to follow before simply cscript running a one line javascript file.
I was under the impression that JavaScript will just run out the box.
PS. Java is the development environment set up for the computer I am trying this on, installed and functional
The right command to print text in the console is
WScript.echo("your text");
The rest works pretty much like javascript.

where do I enter my node commands and why?

Node n00b here. I just installed node on my windows desktop and I'm wondering where I should enter my node commands and why... I have three options (see below). Oh, and if one of these (i.e. node.exe) is not intended for entering node commands, what is it for?
I have looked at the nodejs.org docs and I don't see a clear overview/explanation of what each of these are for and why it's recommended to use one over the other.
Thanks for any insight.
================================================
1) Windows Command Line:
2) Node.js command prompt:
3) Node exe
#1 This is simply window's cmd, you can type node --help there to get a general overview of what you can do with node
#2 Also cmd but with some extra configuration, when you view the properties you'll see it's; C:\Windows\System32\cmd.exe /k "C:\Program Files\nodejs\nodevars.bat" Which basically means it runs cmd with a .bat script, that sets some environment variables, changes the title and prints some welcome message.
#3 This is NodeJS' REPL which evaluates JavaScript within NodeJS' context. ( This is the same as running node from cmd )
Usually you don't enter your code directly, but put it in a file instead. Create this file with the name hello.js:
console.log("Hello World!");
Switch to the directory of your file:
cd C:\Users\yourname\yourdirectory
Then run it with the node command:
node hello.js
And you should get the following output:
Hello World!

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