DEV Community

loading...

Unable to install sharp npm packge on ubuntu

Manoj
・2 min read

OS : Ubuntu 20.04
node v12.19.0
npm module :sharp(module to convert large images in common formats to smaller, web-friendly JPEG, PNG, WebP and AVIF images of varying dimensions).
Alt Text
The image shows error while running the node app after installation of sharp npm module.To resolve the issue follow the steps below:

Step 1 : Complete the installation of sharp using the following command:
npm install sharp
output:

npm WARN task-manager@1.0.0 No description
npm WARN task-manager@1.0.0 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.1 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

audited 297 packages in 2.041s

22 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
Enter fullscreen mode Exit fullscreen mode

Step 2 : Delete "node_modules" folder completely(Dont hesitate,you are not going to lose packages, they are stored in package.json file which you should not edit or delete).

Step 3 : Run the following command:
npm cache clean --force
this command will clean the npm cache memory.
output:

npm WARN using --force I sure hope you know what you are doing.
Enter fullscreen mode Exit fullscreen mode

Step 4 : Install npm packages using ignore script flag as shown below:
npm install --ignore-scripts=false

> sharp@0.26.3 install /home/manoj/Documents/task-manager/node_modules/sharp
> (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)

info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.10.0/libvips-8.10.0-linux-x64.tar.br

> nodemon@2.0.7 postinstall /home/manoj/Documents/task-manager/node_modules/nodemon
> node bin/postinstall || exit 0

Love nodemon? You can now support the project via the open collective:
 > https://opencollective.com/nodemon/donate

npm WARN task-manager@1.0.0 No description
npm WARN task-manager@1.0.0 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.1 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

added 297 packages from 356 contributors and audited 298 packages in 76.916s

22 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
Enter fullscreen mode Exit fullscreen mode

After following this steps, now you should be able to run sharp on your node app. if you are still not able to run sharp, please let me know in comments.

Discussion (0)