user310291
user310291

Reputation: 38190

Node.js cannot find /usr/bin/helloworld.js on windows

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

enter image description here

Upvotes: 3

Views: 748

Answers (1)

nponeccop
nponeccop

Reputation: 13677

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)

Upvotes: 3

Related Questions