Is it possible to run a JavaScript file with node.js on windows? I have been trying to for hours and can't find any more solutions on the internet that work.
I have a js-file that uses scribbletune which only works with node.js.
I have node.js installed and I installed gitbash because it was recommended in a forum.
I tried to run from command prompt and gitbash but nothing seems to happen.
What am I doing wrong? Any help would be very much appreciated.
There is no need to install gitbash to use Node on Windows. It's a handy thing to have if you're used to a *nix environment. If you're not, it just gives you something more to learn, which isn't helpful if you're already in the middle of trying to learn Node.
Just:
Get the Windows installer from https://nodejs.org/en/download/
Run the Windows installer
Create a directory for your project
Open a Command Prompt Window to get a command line
Switch to your project directory
(Optional, but a good idea) Use npm init to create a package.json file (it'll walk you through it)
Install any libs you're going to be using via npm (for instance, npm install scribbletune from your command prompt window)
Put your JavaScript files in that directory
Use node main.js at the command line to run your main file (whatever it's called; main.js is just a placeholder)
Inorder to run a js (java script file) file
step 1. u need to go to the file location where u want to run.
step 2. just use "shift +right click".
u will see a pop-up and go to powershell or cmd.
step 3. type "node FILENAME.js"
final step: you will see the result ^.^
Related
I've been creating a JavaScript game for a project recently and have done it completely on the CodePen website. I now am trying to transfer it to WebStorm to turn it into a basic website. However when I try to run my code I get the following error:
I don't know how to fix it, I've looked everywhere and haven't been able to get some help. Any information would be appreciated.
Simple one, basically the error says, I don't know how to interpret this bit of code that you just gave me. You're missing local install of Node.js and NPM. Get the latest versions of these 2, and then go to File -> Settings -> Language&Frameworks -> Node.js and NPM and in the Node interpreter text box, point it to the path of where node.js was installed.
You're running this JavaScript file with Node.js that is probably not installed on your machine. It seems that you want to run and debug your app in the browser instead. For that you need to create a JavaScript run/debug configuration instead as described here: https://www.jetbrains.com/help/webstorm/debugging-javascript-in-chrome.html
On a linux machnie,
Install nodejs and npm
sudo apt-get install nodejs
sudo apt-get install npm
Get the nodejs installation folder
whereis nodejs
Should print something like:
/usr/bin/nodejs /usr/lib/nodejs /usr/include/nodejs /usr/share/nodejs /usr/share/man/man1/nodejs.1.gz
Go to:
Webstorm-> File -> Languages & Frameworks -> Node interpreter
Copy paste the installation folder to the text box.
Mac OS here. Solved the issue with:
$ brew install nodejs
I'm trying to simply install a stupid package in Node. I use the normal ol' command and it proceeds to tell me it can't find a file or directory (see image below). I've already updated and reinstalled npm, and still the same thing. I'm also running Windows 8. Any ideas, please?
Should I give up developing Node on a Windows machine?
Thanks!
Run npm init first and it will create the package.json file that it is looking for.
So I followed the docs here:
https://github.com/modernizr/modernizr
1) cloned the repo using npm.
2) ran npm install inside modernizr to install its dependencies.
3) tried to run ./bin/modernizr -c lib/config-all.json
I am getting an error:
'.' is not recognized as an internal or external command
I am assuming that this has to do with the windows command line not understanding that I am trying to execute the file at that location. How can I do step 3 on cmd?
Thanks in advance.
Here we go. You need to run the modernizr bin from within node.
node .\bin\modernizr -c .\lib\config-all.json
Run the instructions in PowerShell. It does a better job of support *nix-style syntax and commands than the Command Prompt.
Use Git Bash (part of Git for Windows) or (iof you feel like going in the front door) Minimalist GNU For Windows (http://www.mingw.org/) It works fine.
I am new to node.js and trying to follow this tutorial. I am getting an error on the last command beefy game.js:bundle.js --live. It says sh.exe": beefy: command not found
The beefy package version I am using is 2.1.1
Tried to Google this problem but couldn't find a solution.
I have not followed the tutorial in detail, but the response form the console means that the the console command or program called beefy is not installed. The first word of your input into the console will be interpreted to be a command (a little program) that will run.
For instance cd is a program to change directory and the next thing you enter will specify a directory to which to change.
beefy is not a command/console program that is in your system. (It is not a standard command.) Probably somewhere else in the tutorial you were instructed to install it in one of your various bin/ directories (where shell program commands are stored.)
EDIT:
TL;DR
The fix: install beefy globally (on your machine not for directory only) using npm:
npm install beefy --global
I have installed Node.js on Windows (binary here http://node-js.prcn.co.cc/ ) and can successfully create an HTTP server in console.
Now I have put same instructions in helloworld.js script in bin directory and run with dos prompt
node helloworld.js
and it cannot find in /usr/bin. So I put it under Node.js install directory in usr/bin but same message. I finally tried c:/usr/bin but still failed.
So where should I put my script it on windows ?
screencopy of error
Firstly, there are no such thing as DOS prompt in Windows. And if you take effort to create one (e.g. using DosBox or another virtual machine), node.js is not supposed to be run from a DOS prompt as it's a Windows console application and not a DOS application lol. But calling Windows command prompt DOS prompt is a common misnomer, so I hope you really mean that cmd.exe prompt.
Unlike a previous commenter said, Node.js is fully supported under a complete installation of Cygwin, and almost everything works using the stripped Cygwin tree and node.js windows binaries I provide at http://node-js.prcn.co.cc.
So that /usr/bin problem is not related to an incompatibility with windows. You are even not supposed to put your .js files in bin directory of my tree - any location (and normal absolute or relative Windows path) will work.
I created an example.js in bin directory, created console.log("foo") line in it, went to start menu - windows prompt, cd to the bin directory and executed node helloworld.js without any problems.
So as I cannot reproduce your problem, I have a few questions for you:
1) Does node -v work? If yes, what does it say?
2) Did you extract whole tree (e.g. bin, lib directories etc) or just node.exe from the .7z archive I provide?
3) Are you running shell.cmd or a plain windows prompt from start menu or by running cmd.exe ? (all three ways are supported)