Leah Zorychta
Leah Zorychta

Reputation: 13409

node.js simply does not run

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!

Upvotes: 1

Views: 1354

Answers (1)

Aleksandar Vucetic
Aleksandar Vucetic

Reputation: 14953

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

Upvotes: 1

Related Questions