"require" does not work properly with xml2js

348 views
Skip to first unread message

Udi

unread,
Feb 18, 2011, 8:39:05 PM2/18/11
to nodejs
hi there,
i have been using the xml2js module for a while (thanks!!!) but
suddenly when i try to install it on a new server using node v0.4 and
npm v.3.0-9 the require does not work.
when i explicitly put require('/usr/local/lib/node/xml2js'); it works.
i tried both local install (my user) and shared install. i work with
ubuntu.

i am calling the require from a file which lives in node_modules (btw
i am also using the mysql module in exactly the same way and it works
fine).


any help will be greatly appreciated.


thanks,
udi

tjholowaychuk

unread,
Feb 18, 2011, 11:03:47 PM2/18/11
to nodejs
a bunch of peopel seem to be having issues with require() now, I
havent playeed around with 0.4.0 enough yet to know what is going on
though

Bradley Meck

unread,
Feb 18, 2011, 11:53:10 PM2/18/11
to nod...@googlegroups.com
Take note that npm packaged that use the lib directory (not field) instead of main field of package.json will not work in 0.4.0

Isaac Schlueter

unread,
Feb 19, 2011, 12:35:18 AM2/19/11
to nod...@googlegroups.com
Yep. xml2js doesn't have a "main" field. Bug the author.

On Fri, Feb 18, 2011 at 20:53, Bradley Meck <bradle...@gmail.com> wrote:
> Take note that npm packaged that use the lib directory (not field) instead
> of main field of package.json will not work in 0.4.0
>

> --
> 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.
>

Laurie Harper

unread,
Feb 19, 2011, 12:40:33 AM2/19/11
to nod...@googlegroups.com
So far, all of my problems have been a result of modules that don't define 'main' in package.json, or modules which need "require('module/foo')" changed to "require('module').foo" or vice versa. I'm not sure what causes the latter problems, but it's been a huge PITA...

In the case of xml2js, it's the missing 'main' entry:

$ npm view xml2js | cat -v
npm info it worked if it ends with ok
npm info using n...@0.3.0-8
npm info using no...@v0.4.0
{ name: 'xml2js',
  description: 'Simple XML to JavaScript object converter.',
  'dist-tags': { latest: '0.1.5' },
  maintainers: 'maqr <maqr.lol...@gmail.com>',
  author: 'maqr <maqr.lol...@gmail.com>',
  version: '0.1.5',
  keywords: [ 'xml', 'json' ],
  directories: { lib: './lib' },
  dependencies: { sax: '>=0.1.1' },
  engines: { node: '*' },
npm ok

You can either bug the maintainer to add a 'main' entry to package.json and re-publish (fork/fix and send a pull request to improve the chances he'll do it, and while you're at it, add the git repo to package.json too... it's here: https://github.com/maqr/node-xml2js/); or just fork, fix and 'npm link' or 'npm install' your local copy.

L.

--
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.


-- 
Laurie Harper



Laurie Harper

unread,
Feb 19, 2011, 12:40:57 AM2/19/11
to nod...@googlegroups.com
lol, what he said ;-) [beat me by a hair...]

--
Laurie Harper
http://laurie.holoweb.net/

Udi

unread,
Feb 20, 2011, 1:27:07 AM2/20/11
to nodejs
Thanks all.

On Feb 18, 9:40 pm, Laurie Harper <lau...@holoweb.net> wrote:
> lol, what he said ;-) [beat me by a hair...]
>
> On 2011-02-19, at 12:35 AM, Isaac Schlueter wrote:
>
>
>
>
>
>
>
>
>
> > Yep.  xml2js doesn't have a "main" field. Bug the author.
>
Reply all
Reply to author
Forward
0 new messages