1

I installed and ran node.js just fine on my mac, but even if I do this on windows

chdir c:\testfolder
node example.js

then I get this error:

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
Error: Cannot find module 'c:\testfolder\example.js'

at Function._resolveFilename <module.js:322:11>
at Function._load <module.js:299:25>
at Array.0 <module.js:499:10>
at EventEmitter._tickCallback <node.js:192:40>

I'm only even trying to run the example code on the nodejs website:

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');

I don't understand, that file DOES exist!

7
  • How did you install Node.js and in what shell are you running it under Windows? (cmd.exe, command.com, Cygwin, Git Bash, PowerShell, some shell I'm not aware of?) I've never run into the issue you're mentioning on Windows, Mac, or Linux. Commented Mar 20, 2012 at 23:29
  • Are you certain that the file exists... I hate to ask if you didn't mess up the file extension or something? Try running this dl.dropbox.com/u/17781372/example.js - installed node just 5 minutes ago on my windows box and this runs fine. Commented Mar 20, 2012 at 23:39
  • @DavidEllis I just used the Windows installer, I'm using cmd.exe (I even tried right clicking and running as Administrator) Commented Mar 21, 2012 at 0:02
  • @MattEsch Esch I know I must look crazy given the error but the file does exist. I get the same error on yours as well. Commented Mar 21, 2012 at 0:02
  • @DavidEllis my path: C:\Users\Smith>echo %PATH% C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x8 6)\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\ Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;c:\Program Fil es (x86)\ATI Technologies\ATI.ACE\Core-Static;c:\Program Files (x86)\Common File s\Roxio Shared\DLLShared\;c:\Program Files (x86)\Common Files\Roxio Shared\12.0\ DLLShared\;C:\Program Files (x86)\Windows Live\Shared;C:\Users\Smith\AppData\ Roaming\npm;C:\Program Files (x86)\nodejs\ Commented Mar 21, 2012 at 19:00

1 Answer 1

1

Most likely your file is not named example.js, but example.js.txt if you created it using notepad, and it is not turned on your machine to show file extensions for known file types :)

You will be able to see your real file name when you type: chdir c:\testfolder and then dir

Sign up to request clarification or add additional context in comments.

4 Comments

Nope, not the case I'm afraid.
Then, I'm not sure what else can be the case. Can you show us what "dir" command says"? Anyway, I really think that in this case (with the symptoms you are reporting) nothing else can be a problem but that your file is not named example.js but something different (most likely example.js.txt).
It's not called .js.txt, I am 1000% sure of that :P
try downloading and installing the newest version then...I've just did that and it works perfectly fine. No other ideas from me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.