user3776320
user3776320

Reputation: 53

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.

Upvotes: 3

Views: 11209

Answers (2)

aswanth bonthala
aswanth bonthala

Reputation: 261

As per latest changes made in library npm install xmldom is no longer supported. We should use npm i @xmldom/xmldom

Since version 0.7.0 this package is published to npm as @xmldom/xmldom and no longer as xmldom, because we are no longer able to publish xmldom.

NPM documentation available here for more details

Upvotes: 1

japrescott
japrescott

Reputation: 5025

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

Upvotes: 8

Related Questions