Import cheerio module to TypeScript app

Viewed 10261

I try to import cheerio to my typescript based app.

import {cheerio}  from 'cheerio';
console.log(cheerio); //undefined

from package.json:

...
"@types/cheerio": "^0.22.5
...
3 Answers

It works for me import * as cheerio from 'cheerio';

it's exported as defalut. try

import cheerio from 'cheerio'

1 - install cheerio

npm i cheerio

2 - import the whole package

import cheerio from 'cheerio'

Note: you can also just import the load function

import { load } from 'cheerio'
Related