Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I cant install sharp using npm

Tags:

node.js

sharp

I cant install sharp library using sudo npm install sharp.

The terminal output:

[email protected] install /Users/kozakiewicz/node_modules/sharp (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)

info sharp Using cached /Users/kozakiewicz/.npm/_libvips/libvips-8.8.1-darwin-x64.tar.gz
ERR! sharp EACCES: permission denied, mkdir '/Users/kozakiewicz/node_modules/sharp/vendor'
info sharp Attempting to build from source via node-gyp but this may fail due to the above error
info sharp Please see https://sharp.pixelplumbing.com/page/install for required dependencies
gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/Users/kozakiewicz/node_modules/sharp/build'
gyp ERR! System Darwin 18.7.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/kozakiewicz/node_modules/sharp
gyp ERR! node -v v10.16.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
npm WARN enoent ENOENT: no such file or directory, open '/Users/kozakiewicz/package.json'
npm WARN [email protected] requires a peer of gatsby@^2.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of node-sass@^4.9.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of webpack@^3.0.0 || ^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of gatsby@^2.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of gatsby@^2.0.33 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of gatsby@^2.2.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of gatsby@^2.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of gatsby-transformer-sharp@^2.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of webpack@^3.0.0 || ^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN kozakiewicz No description
npm WARN kozakiewicz No repository field.
npm WARN kozakiewicz No README data
npm WARN kozakiewicz No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `(node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/kozakiewicz/.npm/_logs/2019-10-14T21_07_02_376Z-debug.log
like image 766
Kozakiewicz1221 Avatar asked Oct 14 '19 21:10

Kozakiewicz1221


People also ask

Why npm install is not working?

The Npm command not found error can appear when you install or upgrade npm. On Windows, the cause of this error could be that a PATH or system variable is not correctly set. The error can also occur if you do not have npm or Node. js installed, have an outdated version, or have permission issues.

How do I force an npm package to install?

The -f or --force argument will force npm to fetch remote resources even if a local copy exists on disk. The -g or --global argument will cause npm to install the package globally rather than locally.


Video Answer


2 Answers

Delete all dependencies with rm -rf node_modules and also delete /home/USER/.npm/_libvips/libvips-8.8.1-linux-x64.tar.gz and try again That should fix.

like image 182
Fernando Javier Averanga Avatar answered Oct 19 '22 10:10

Fernando Javier Averanga


This has a few probable causes, the one that got me was node version.

I had node --version set to 14.0.0 where it should be the same as whats set in the environment.

  1. Install nvm (node version manager)
  2. find what version of node you need to use
  3. nvm use 10 or replace 10 with your node version value.
like image 2
mewc Avatar answered Oct 19 '22 09:10

mewc