New in node js

630 views
Skip to first unread message

Ronnie

unread,
Jun 4, 2012, 2:49:12 AM6/4/12
to nodejs
Hi ,
I am very new in node js . I have installed node-v0.6.18.msi in my
local windows machine.

I am unabl eto run a hello world program.

Could you please help me in this respect!

Thanks in advance.

Ronnie

unread,
Jun 4, 2012, 4:16:54 AM6/4/12
to nodejs
Hi,

I am successfull in running the hello world app.

Now I am trying to run some other app and getting the following
error .

module.js:337
throw new Error("Cannot find module '" + request + "'");
^
Error: Cannot find module 'multipart'
at Function._resolveFilename (module.js:337:11)
at Function._load (module.js:279:25)
at Module.require (module.js:359:17)
at require (module.js:375:17)
at Object.<anonymous> (C:\upload.js:2:17)
at Module._compile (module.js:446:26)
at Object..js (module.js:464:10)
at Module.load (module.js:353:31)
at Function._load (module.js:311:12)
at Array.0 (module.js:484:10)

Please help in this regard!

Thanks in advance.

On Jun 4, 11:49 am, Ronnie <ankur...@tcs.com> wrote:
> Hi ,
> I am verynewinnodejs . I have installednode-v0.6.18.msi in my

yogesh agrawal

unread,
Jun 4, 2012, 4:19:43 AM6/4/12
to nod...@googlegroups.com
multipart module is not in node_modules.

install it by using npm install command


--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en



--
Yogesh Agrawal
+91-9351507770

Ronnie

unread,
Jun 4, 2012, 4:28:13 AM6/4/12
to nodejs
Thanks , can you guide me on this.

I have installed node-v0.6.18.msi exe and the node has been installed
in

C:\Program Files\nodejs .

What next ?

How to run the npm install command?

Plese guide.

Hello world is running.

Ronnie

unread,
Jun 4, 2012, 5:18:48 AM6/4/12
to nodejs
I ran the npm install commnad and got the following exception:

npm http GET https://github.com/isaacs/ronnjs/tarball/master
npm ERR! failed to fetch https://github.com/isaacs/ronnjs/tarball/master

npm ERR! Error: getaddrinfo ENOENT
npm ERR! at errnoException (dns.js:31:11)
npm ERR! at Object.onanswer [as oncomplete] (dns.js:140:16)
npm ERR! You may report this log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <np...@googlegroups.com>
npm ERR!
npm ERR! System Windows_NT 5.1.2600
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program
Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "instal
npm ERR! cwd C:\Program Files\nodejs\node_modules\npm
npm ERR! node -v v0.6.18
npm ERR! npm -v 1.1.21
npm ERR! syscall getaddrinfo
npm ERR! code ENOTFOUND
npm ERR! message getaddrinfo ENOENT
npm ERR! errno {}
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! C:\Program Files\nodejs\node_modules\npm\npm-debug.log
npm not ok

What is the problem?

Please help on this regard!

On Jun 4, 1:28 pm, Ronnie <ankur...@tcs.com> wrote:
> Thanks , can you guide me on this.
>
> I have installednode-v0.6.18.msi exe and thenodehas been installed
> in
>
> C:\Program Files\nodejs .
>
> What next ?
>
> How to run the npm install command?
>
> Plese guide.
>
> Hello world is running.
>
> On Jun 4, 1:19 pm, yogesh agrawal <saggiyog...@gmail.com> wrote:
>
>
>
>
>
>
>
> > multipart module is not in node_modules.
>
> > install it by using npm install command
>
> > On Mon, Jun 4, 2012 at 1:46 PM, Ronnie <ankur...@tcs.com> wrote:
> > > Hi,
>
> > > I am successfull in running the hello world app.
>
> > > Now I am trying to run some other app and getting the following
> > > error .
>
> > > module.js:337
> > >    thrownewError("Cannot find module '" + request + "'");

Srirangan

unread,
Jun 4, 2012, 5:19:28 AM6/4/12
to nod...@googlegroups.com
I see this occasionally on Ubuntu. Just re-run the command.

Srirangan  |  +91 9711 477 595  |  About   GitHub  LinkedIn  Twitter  |  Review19  "Collaborate & Track Decisions"

Ronnie

unread,
Jun 4, 2012, 5:26:58 AM6/4/12
to nodejs
Hi Srirangan,

I ran many times , the same error repeated.

Can you / any one guide on how to run an assynchronous file upload
application using node.js in windows machinestep by step.

Thanks in advance.

On Jun 4, 2:19 pm, Srirangan <sriran...@gmail.com> wrote:
> I see this occasionally on Ubuntu. Just re-run the command.
>
> Srirangan  |  +91 9711 477 595  |  About <http://srirangan.net/about>
> GitHub <https://github.com/Srirangan>
> LinkedIn<http://www.linkedin.com/in/srirangan>
>   Twitter <http://twitter.com/srirangan>  |  Review19
> <http://review19.com>  "Collaborate
> & Track Decisions"
>
>
>
>
>
>
>
> On Mon, Jun 4, 2012 at 2:48 PM, Ronnie <ankur...@tcs.com> wrote:
> > I ran the npm install commnad and got the following exception:
>
> > npm http GEThttps://github.com/isaacs/ronnjs/tarball/master
> > npm ERR! failed to fetchhttps://github.com/isaacs/ronnjs/tarball/master

Srirangan

unread,
Jun 4, 2012, 5:28:06 AM6/4/12
to nod...@googlegroups.com
I'm sorry I'm not familiar with Node development on Windows. 

I remember writing a file upload tutorial on HowToNode.org .. but that's not tested on Windows.

- Sri

Srirangan  |  +91 9711 477 595  |  About   GitHub  LinkedIn  Twitter  |  Review19  "Collaborate & Track Decisions"

Rohit Singh

unread,
Jun 4, 2012, 5:29:52 AM6/4/12
to nod...@googlegroups.com

try running it as admin. I guess it might help.

On Mon, Jun 4, 2012 at 2:56 PM, Ronnie <anku...@tcs.com> wrote:



--
Rohit Singh
+91-9958563916

Angel Java Lopez

unread,
Jun 4, 2012, 5:30:39 AM6/4/12
to nod...@googlegroups.com
One comment:

Ronnie, I'm an old programmer, I used to program in mainframes, punched cards, minicomputers, some old Unix, even Xenix ;-)... but the last two decades, my career was in Windows.

One thing a Windows developer like me, found a bit not explicit stated (maybe I wrong, but...) is that npm can be (and usually is) invoked AT A WORKING FOLDER. Your .msi installation should add the node path to your PATH. If not, I highly recommended to add it.

Then, you can enter:

cd \myusualdevfolder
mkdir mytest
cd mytest
npm install nodeunit

then, in your mytest folder, you will have a node_modules folder, with nodeunit subfolder.

Can you run npm in this way, and install something not in your system, like nodeunit?

(or try npm install simplemvc (my project ;-))

I see that you are trying to run

npm install ....

from the npm directory. Hmmm... It's not the usual way.

Please, can you do the above steps? have node installation folder in your PATH?

Angel "Java" Lopez

yogesh agrawal

unread,
Jun 4, 2012, 5:40:38 AM6/4/12
to nod...@googlegroups.com
I tried npm installed command on windows, but no such error.

tested on v0.6.6

Angel Java Lopez

unread,
Jun 4, 2012, 5:43:46 AM6/4/12
to nod...@googlegroups.com
Ah!

Ronnie, a key point to understand require (and npm work) is:


lookup at

Loading from node_modules Folders#

If the module identifier passed to require() is not a native module, and does not begin with '/''../', or'./', then node starts at the parent directory of the current module, and adds /node_modules, and attempts to load the module from that location.


Another good resource is:

BUT WARNING: require.paths doesn't exist anymore. It was removed in Node 0.5.x (AFAIK)

The final piece to understand require, at the first link:

Loading from the global folders#

If the NODE_PATH environment variable is set to a colon-delimited list of absolute paths, then node will search those paths for modules if they are not found elsewhere. (Note: On Windows, NODE_PATH is delimited by semicolons instead of colons.)

If you can install something complex, like 

npm install nodeunit

you will see that node_modules/nodeunit has another node_modules subfolder! Russian dolls! ;-)

Well, nodeunit inside code require(...) USES the noneunit/node_modules subfolder for its own dependencies.

This way of package search is very useful and interesting. Maybe, it's a new way to Ruby developers, or NuGet users. It avoid some version collisions.

If you run

npm install -g nodeunit

the module is usually installed into your user folder. In my case, in

<myuserfolder>/AppData/Roaming/npm

Your PATH should be point to this folder (usually, the .msi did this work).

In such way, the new module can install line commands. In my case, I have nodeunit.cmd in this folder.

After resolving your npm install issue, try a global install with great output:

npm install -g geddy


and check if that roaming directory there is a new geddy.cmd

Hope all this helps, enjoy!

Ronnie

unread,
Jun 4, 2012, 6:00:45 AM6/4/12
to nodejs
Thanks .

I ran the msi , for which the node js got installed in C:\Program Files
\nodejs\node_modules\npm.

PATH is also set . I can run the hellowrld programes but whihle
running the following program :

var express = require('express');

var app = express.createServer(express.logger());

app.put('/', function(req, res) {
res.contentType('json');
res.send(JSON.stringify({ status: "success" }));
});

var port = process.env.PORT || 3000;

app.listen(port, function() {
console.log("Listening on " + port);
});

I get the following errors.

module.js:337
throw new Error("Cannot find module '" + request + "'");
^
Error: Cannot find module 'express'
at Function._resolveFilename (module.js:337:11)
at Function._load (module.js:279:25)
at Module.require (module.js:359:17)
at require (module.js:375:17)
at Object.<anonymous> (C:\node1.js:1:77)
at Module._compile (module.js:446:26)
at Object..js (module.js:464:10)
at Module.load (module.js:353:31)
at Function._load (module.js:311:12)
at Array.0 (module.js:484:10)

I have been given the suggestion to run npm install to include all the
modules , but modules are already there !

What should i DO?



On Jun 4, 2:30 pm, Angel Java Lopez <ajlopez2...@gmail.com> wrote:
> One comment:
>
> Ronnie, I'm an old programmer, I used to program in mainframes, punched
> cards, minicomputers, some old Unix, even Xenix ;-)... but the last two
> decades, my career was in Windows.
>
> One thing a Windows developer like me, found a bit not explicit stated
> (maybe I wrong, but...) is that npm can be (and usually is) invoked AT A
> WORKING FOLDER. Your .msi installation should add the node path to your
> PATH. If not, I highly recommended to add it.
>
> Then, you can enter:
>
> cd \myusualdevfolder
> mkdir mytest
> cd mytest
> npm install nodeunit
>
> then, in your mytest folder, you will have a node_modules folder, with
> nodeunit subfolder.
>
> Can you run npm in this way, and install something not in your system, like
> nodeunit?
>
> (or try npm install simplemvc (my project ;-))
>
> I see that you are trying to run
>
> npm install ....
>
> from the npm directory. Hmmm... It's not the usual way.
>
> Please, can you do the above steps? have node installation folder in your
> PATH?
>
> Angel "Java" Lopezhttp://www.ajlopez.comhttp://twitter.com/ajlopez
>
>
>
>
>
>
>
> On Mon, Jun 4, 2012 at 6:19 AM, Srirangan <sriran...@gmail.com> wrote:
> > I see this occasionally on Ubuntu. Just re-run the command.
>
> > Srirangan  |  +91 9711 477 595  |  About <http://srirangan.net/about>
> > GitHub <https://github.com/Srirangan>  LinkedIn<http://www.linkedin.com/in/srirangan>
> >   Twitter <http://twitter.com/srirangan>  |  Review19<http://review19.com>  "Collaborate
> > & Track Decisions"
>
> > On Mon, Jun 4, 2012 at 2:48 PM, Ronnie <ankur...@tcs.com> wrote:
>
> >> I ran the npm install commnad and got the following exception:
>
> >> npm http GEThttps://github.com/isaacs/ronnjs/tarball/master
> >> npm ERR! failed to fetchhttps://github.com/isaacs/ronnjs/tarball/master

Angel Java Lopez

unread,
Jun 4, 2012, 6:13:50 AM6/4/12
to nod...@googlegroups.com
Hmmm.. it's rare..

Can you share with us the output of

tree node_modules

from your working directory? It could be large, but is the only idea I have.

Your PATH should point to
c:\Program Files\nodejs

Every day, I run node in Windows Vista, Windows Server 2008, Windows 7, without major glitches

Any other ideas?

Ronnie

unread,
Jun 4, 2012, 6:30:55 AM6/4/12
to nodejs
Please have a look :

C:\PROGRAM FILES\NODEJS\NODE_MODULES
└───npm
├───bin
│ └───node-gyp-bin
├───doc
│ ├───api
│ └───cli
├───html
│ ├───api
│ └───doc
├───lib
│ └───utils
│ ├───completion
│ └───npm-registry-client
├───man
│ ├───man1
│ └───man3
├───node_modules
│ ├───abbrev
│ │ └───lib
│ ├───archy
│ ├───block-stream
│ ├───chownr
│ ├───fstream
│ │ └───lib
│ ├───fstream-npm
│ │ └───node_modules
│ │ └───fstream-ignore
│ ├───graceful-fs
│ ├───inherits
│ ├───ini
│ ├───lru-cache
│ │ └───lib
│ ├───minimatch
│ ├───mkdirp
│ ├───node-gyp
│ │ ├───bin
│ │ ├───legacy
│ │ │ └───tools
│ │ │ └───gyp
│ │ │ ├───buildbot
│ │ │ ├───pylib
│ │ │ │ └───gyp
│ │ │ │ └───generator
│ │ │ ├───samples
│ │ │ └───tools
│ │ │ └───Xcode
│ │ │ └───Specifications
│ │ ├───lib
│ │ │ └───util
│ │ └───node_modules
│ │ ├───ansi
│ │ │ └───lib
│ │ └───glob
│ ├───node-uuid
│ ├───nopt
│ │ ├───bin
│ │ └───lib
│ ├───proto-list
│ ├───read
│ │ └───lib
│ ├───request
│ │ └───vendor
│ │ └───cookie
│ ├───rimraf
│ ├───semver
│ │ └───bin
│ ├───slide
│ │ └───lib
│ ├───tar
│ │ └───lib
│ ├───uid-number
│ └───which
│ └───bin
├───scripts
└───test
└───packages
├───npm-test-blerg
├───npm-test-bundled-git
├───npm-test-env-reader
├───npm-test-files
│ └───sub
├───npm-test-ignore
│ └───sub
├───npm-test-missing-bindir
├───npm-test-optional-deps
├───npm-test-platform
├───npm-test-platform-all
├───npm-test-private
├───npm-test-shrinkwrap
├───npm-test-test-package
└───npm-test-url-dep

C:\Program Files\nodejs>

Thanks in advnace.

I wanna execute the following file :

var http = require('http');
var multipart = require('multipart');
var sys = require('sys');

var server = http.createServer(function(req, res) {
switch (req.uri.path) {
case '/':
display_form(req, res);
break;
case '/upload':
upload_file(req, res);
break;
default:
show_404(req, res);
break;
}
});
server.listen(8000);

function display_form(req, res) {
res.sendHeader(200, {'Content-Type': 'text/html'});
res.sendBody(
'<form action="/upload" method="post" enctype="multipart/form-
data">'+
'<input type="file" name="upload-file">'+
'<input type="submit" value="Upload">'+
'</form>'
);
res.finish();
}

function upload_file(req, res) {
req.setBodyEncoding('binary');

var stream = new multipart.Stream(req);
stream.addListener('part', function(part) {
part.addListener('body', function(chunk) {
var progress = (stream.bytesReceived / stream.bytesTotal *
100).toFixed(2);
var mb = (stream.bytesTotal / 1024 / 1024).toFixed(1);

sys.print("Uploading "+mb+"mb ("+progress+"%)\015");

// chunk could be appended to a file if the uploaded file needs
to be saved
});
});
stream.addListener('complete', function() {
res.sendHeader(200, {'Content-Type': 'text/plain'});
res.sendBody('Thanks for playing!');
res.finish();
sys.puts("\n=> Done");
});
}

function show_404(req, res) {
res.sendHeader(404, {'Content-Type': 'text/plain'});
res.sendBody('You r doing it rong!');
res.finish();
}

Please suggest how can I execute this js!

Thanks in advance.

My classpath : C:\Program Files\Java\jdk1.6.0_21\bin;C:\Program Files
\nodejs\

Angel Java Lopez

unread,
Jun 4, 2012, 6:35:48 AM6/4/12
to nod...@googlegroups.com
First idea:

Try it in another folder, as I suggested in a previous email.

The USUAL way is to work outside that folder. So your modules will be installed in your working folder, maybe

cd c:\Dev\NodeJs
mkdir mytest
cd mytest

and then, work from that folder.

Try then
node

to be sure if it works

Then, try your hello app
Then, run

npm install express

and try your express application.

But ever from your working directory. Keep the node folder to be managed by node and npm.

If you download an application (or git clone one), usually the application folder has a package.json. Then, go to that application folder and run

npm install

Npm reads the package.json, discovering all the dependencies the application has. 

Ronnie

unread,
Jun 4, 2012, 7:26:47 AM6/4/12
to nodejs
Ok thanx , I will try . For the time being I have to switch to some
other prirotiy.

Thanks again for your prompt response.

Jithin A G

unread,
Mar 28, 2014, 2:28:59 AM3/28/14
to nod...@googlegroups.com
how to submit file in this functions, i also run this code in Ubuntu comd line

Dhananjay kumar

unread,
Mar 28, 2014, 2:39:15 AM3/28/14
to nod...@googlegroups.com
Hi , 

may be this video blog post of mine will help you ! 



Thanks 
@debug_mode





--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages