Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Cannot find module 'xmldom'

Tags:

node.js

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.

like image 268
user3776320 Avatar asked Sep 08 '25 15:09

user3776320


2 Answers

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

like image 167
japrescott Avatar answered Sep 10 '25 06:09

japrescott


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

like image 40
aswanth bonthala Avatar answered Sep 10 '25 08:09

aswanth bonthala