sharp is not a function

Created on 11 Oct 2019  路  2Comments  路  Source: lovell/sharp

Here i am importing sharp and then try to use sharp, it is giving me error "sharp is not a function"
if anyone aware about this, then it would be great.

import * as sharp from "sharp";

const imageToResize = sharp(image);
imageToProcess.metadata().then((metadata) => {
})

question

All 2 comments

Try importing sharp with import sharp from 'sharp';.

A namespace-style import like import as from cannot be called or constructed, and will cause a failure at runtime. If you need to import additional properties from sharp you can destructure them, like so: import sharp, { OverlayOptions } from 'sharp';

Thank you @Fdebijl.
It worked for me.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

terbooter picture terbooter  路  3Comments

tomercagan picture tomercagan  路  3Comments

jaekunchoi picture jaekunchoi  路  3Comments

AVVS picture AVVS  路  3Comments

vermin1337 picture vermin1337  路  3Comments