2

I am creating a node.js application written in Typescript. Its one of the functionality is to parse HTML file. But I can't seem to find the HTML parser written in Typescript.

As, normal npm modules specified in HTML-parser on Node.js are not importing in my application.

I have tried installing the node.js module like

npm install domhandler

and, then imported the module in my main.ts file like

import * as parser from "htmlparser2"

It was throwing error

Cannot find module 'htmlparser2'

Is there any way I can import these normal npm modules in my Typescript node application?
Or, is there any typescript module which I can use to parse HTML file?

4
  • Why are they not importing? Commented Nov 26, 2016 at 5:46
  • Please provide code so that we will know what you have done and how to correct if something is wrong. Commented Nov 26, 2016 at 6:55
  • I have updated the question with what I have tried. Commented Nov 26, 2016 at 10:30
  • 4
    If you are using version 2.x of typescript then you simply need to npm install @types/domhandler to install the definition files for this module, otherwise you'll need to use typings. Commented Nov 26, 2016 at 11:01

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.