node.jsxmldom

Error: Cannot find module 'xmldom'


I am getting this error, i have installed xmldom using

npm install xmldom

, into the directory

C:\Program Files (x86)\nodejs_10.35\node_modules\npm\node_modules.

i checked the package.json inside xmldom, it is intact and when i run my script with this line

var DOMParser = require('xmldom').DOMParser; 

I get the error.

I searched a lot to resolve this issue, I verified all the suggestions but none worked. In some thread someone suggested to install wherever app.js file is present, but I could not find that in my nodejs installation directory.


Solution

  • you need to npm install xmldom in the directory (or in a parent directory) of the directory where your script resides that does the require(xmldom) and not where node is installed