Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Unable to load node.js package

Unable to load node.js package


I have a node.js project where I'm trying to load and parse .xml files. In an attempt to do this, I was going to rely on the DOM Parser via the following command:

npm install xmldom

The package was successfully installed. However, when I attempt to execute my Code via mocha, I get an error that says: "Error: Cannot find module 'xmldom'". My code works fine until I add the following line at the top of my code:

var dom = require('xmldom');

If I comment out the line, my code works. But, if I remove the commments, to make the code active, I get the error again. I haven't written anything to actually parse the xml file yet. I'm just trying to import the dom parser at this point.

I also tried loading the xmldom package globally with the following command:

npm install -g xmldom

That did not solve my problem either. What am I missing?

Problem courtesy of: Node Newbie


I wrote a blog post explaining what to look for when you get a Cannot find module 'xmldom' error.

Solution courtesy of: Chad Campbell


View additional discussion.

This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Unable to load node.js package


Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription