I'm new to programming and I just started learning JS. I tried running my first code via 'code runner' on Visual Studio Code but it wasn't giving me the output. enter image description here
You need to install NodeJS first in order to run the JavaScript on your machine. You can download it here. Then, you should make sure that Node path is added. After that restart VS Code and run it again.
Related
I'm relatively new to using IDEs and recently started using VSCode for class. I'm using the Code Runner extension and working on a Mac. Whenever I go to run a piece of code I receive the following message in my terminal:
The default interactive shell is now zsh.
To update your account to use zsh, please run chsh -s /bin/zsh.
For more details, please visit https://support.apple.com/kb/HT208050.
Could someone help explain what exactly this message means? I think for class we want to use the Bash shell so I'm hesitant to make any changes to the current settings but I don't want it to interfere with my ability to run/test code.
The tutor of my video tutorial compiles javascript/react on save with his VS Code editor. Mine dont.
How can I config VS Code to do this?
Remark:
I find solution for typescript "Visual Studio Code - compile on save", but suggested solution does not work for me.
#added information:
the project is created with create.react-app. npm start opens chrome, and compilation errors are then shown in Chrome's DEV-Console, as noted by Shishani . My tutor has the code compiled on VS Code Terminal console. This offers a quick check of the code compilation before I go to webbrowser, to check for errors there, which seems to me much more intimidating with it's long callstacks.
If you create your React project with create-react-app, and then start it with npm start, it compiles automatically on save. Also, if it's not a React project, but just JS/HTML/CSS, you can open your project with the "Live Server" extension in VSCode, and it will update your page every time you save a file in your VSCode workspace.
You can even do like I do, and enable constant autosave, with the AutoSave: afterDelay setting in VSCode (if you dare), and then set the save delay to a super small number (mine is 2ms) so you don't even need to hit save anymore (go to File>Preferences>Settings>[Search "Auto Save"]).
If you have created react project using there official cli tool (create-react-app) then on saving js files it gets re-compile. This is because they are using webpack bundler behind the scene.
If you have created normal html or js files without any such cli tools then it won't work directly, You have to use some kind of bundler with dev-server support to do it.
Parcel! is a great bundler to use without configuration
Good morning, beginner here.
Im reading a book where the author tells me to run a command from the command line to execute a program made in js, source:https://eloquentjavascript.net/20_node.html#h_TUzbi7lU/0
I've downloaded the lastest recommended version of nodejs (12.13.0 LTS), made the js file the book tells me to run (I made it in visualstudio because renaming a .txt file with the code to .js didn't do the job) and copy pasted it in the folder where the nodejs folder is, ran the command (ran several others that i thought would work as well) and i get this error:
This other thread had a similar problem with a solution, while it might solve the problem of running the program, it doesn't run it in the way the author of the book im reading tells me to, How to run a hello.js file in Node.js on windows?
Hello and welcome to SO.
You seem to have run node then hello in the node REPL, which is, of course an undefined variable.
Exit out of node and run node hello.js. This will use node to execute the code in the hello.js file if you are in the same folder/directory as it.
Just close this node terminal and start a new command prompt from the desired location and run "node hello.js" in a single line.
I am trying to run JavaScript code in Atom with Script package. It can run Python successfully, but with JS files it gives the following error message:
The system cannot find the file specified.
I had the same problem while analyzing some JavaScript code of an extension for Chrome.
Using: Windows 7 64Bit Atom:1.24.0 x64
Since I my coding Folder is somewhere else I copied the files in that folder. Let’s say:
C:\Users\USER\CodingStuff\
then it started working. I have also tried adding the extension file the Sources via:
1 - CTRL+SHIFT+I
2- Right click -> add folder to workspace
But that did not work.
Side note: node.js has to be installed on the system.
Hope it helps.
I know I am late, but if any other faces the same issue, my answer will be helpful.
Assumed that you want to run your javascript outside browser and you installed node.js.
There is a bug in "script" package of Atom. Check ur path of the script if there are spaces then this leads to the aforementioned error. Work around is remove spaces.
for ex:
E:\Java script\trial.js
change to:
E:\Javascript\trial.js
I created a Test.js file and wrote two lines of JS code in it:
var a = 5;
console.log("The result is = " + a);
The output should be:
"The result is = 5"
Is there a way I can see this in Aptana Scripting console, instead of integrating the JS code in a HTML file and saving/refreshing it?
Can any other IDE, say Netbeans help, if not Aptana?
Any advise would be highly appreciated.
Regards
Roy
I think that it would be best if you give Node.js a try. This way, you get to call node test.js on a console window and see the result.
I'm pretty sure that console is meant for viewing the output of Aptana's Ruby-based commands (installed under the Commands menu). It might be possible to follow the instructions here: http://www.chromium.org/for-testers/enable-logging and then tail the resulting log file in a Terminal panel (not the same as a console window).
I'm afraid it is not possible.
But What I did was to setup a simple workbench.html file, where in the header I put
[...]
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="js/myJsFile.js"></script>
and then modified the myJsFile.js and saved it.
Another very intersting possibility is given by http://www.developer.nokia.com/Community/Wiki/Aptana_WRT_Plugin:_Displaying_log_messages_in_Output_console
just check it
It's not exactly what you asked, but it might point you in the right direction. There's a project called EclipseMonkey ... I'm not sure the status. Here's a working (?) example. Your mileage will vary. http://blogs.edgehill.ac.uk/webservices/2008/10/16/aptana-outline-auto-expansion-monkeyed/
What you can do is you can download node.js from node.js, download the package and follow the installation instructions on the screen.
If using a Windows, the node.js package comes with its own interactive command prompt which you can open. To run a js file on windows, open the windows command prompt, type in node, then the name of your file e.g. test.js. Node.js should run your file.
If using a Mac, the node.js package runs through the terminal application on the mac. To run a file, type in node, then the name of your file e.g. test.js, node.js should run the file.
Aptana Studio 3 has the ability to open the terminal inside the IDE itself. Save your file in Aptana Studio and follow the instructions to run a file on the mac.
By the way, keep your files labelled in lowercase letters, I tried using Uppercase for the first letter and it did not work.
Hope that helps.