Error installing Gulp-imagemin via NPM

Asked

Viewed 79 times

1

I am trying to install Gulp-imagemin for image optimization via NPM but errors are occurring.

When I run the following command on the terminal, permission errors return.

sudo npm install gulp-imagemin --save-dev

Mistakes:

[email protected] postinstall /home/bruno/workspace/gds-wp2/node_modules/gifsicle
> node lib/install.js

  ✔ gifsicle pre-build test passed successfully

> [email protected] postinstall /home/bruno/workspace/gds-wp2/node_modules/jpegtran-bin
> node lib/install.js

  ⚠ EACCES: permission denied, mkdir '/home/bruno/workspace/gds-wp2/node_modules/jpegtran-bin/vendor'
  ⚠ jpegtran pre-build test failed
  ℹ compiling from source
  ✖ Error: EACCES: permission denied, mkdir '/home/bruno/workspace/gds-wp2/node_modules/jpegtran-bin/300d0d91-da15-4485-99b7-54a17a906294'

> [email protected] postinstall /home/bruno/workspace/gds-wp2/node_modules/optipng-bin
> node lib/install.js

  ⚠ EACCES: permission denied, mkdir '/home/bruno/workspace/gds-wp2/node_modules/optipng-bin/vendor'
  ⚠ optipng pre-build test failed
  ℹ compiling from source
  ✖ Error: EACCES: permission denied, mkdir '/home/bruno/workspace/gds-wp2/node_modules/optipng-bin/14ef0873-de46-43a9-bd55-a944ce91d156'
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

+ [email protected]
added 243 packages from 150 contributors and audited 11368 packages in 125.035s
found 10 vulnerabilities (5 low, 2 moderate, 3 high)
  run `npm audit fix` to fix them, or `npm audit` for details

And then when I try to turn the gulp img in the terminal for image optimization, Gulp returns the following error:

[16:46:07] Using gulpfile ~/workspace/gds-wp2/gulpfile.js
[16:46:07] Starting 'img'...
[16:46:07] 'img' errored after 304 ms
[16:46:07] Error in plugin "gulp-imagemin"
Message:
    spawn /home/bruno/workspace/gds-wp2/node_modules/optipng-bin/vendor/optipng ENOENT
Details:
    errno: ENOENT
    code: ENOENT
    syscall: spawn /home/bruno/workspace/gds-wp2/node_modules/optipng-bin/vendor/optipng
    path: /home/bruno/workspace/gds-wp2/node_modules/optipng-bin/vendor/optipng
    spawnargs: -strip,all,-clobber,-fix,-o,3,-out,/tmp/803070bf-7ad3-4981-a2a7-4d6550a09b6f,/tmp/6e4684d9-75a5-4557-80a1-1867e6884065
    killed: false
    stdout: 
    stderr: 
    failed: true
    signal: null
    cmd: /home/bruno/workspace/gds-wp2/node_modules/optipng-bin/vendor/optipng -strip all -clobber -fix -o 3 -out /tmp/803070bf-7ad3-4981-a2a7-4d6550a09b6f /tmp/6e4684d9-75a5-4557-80a1-1867e6884065
    timedOut: false
    fileName: /home/bruno/workspace/gds-wp2/assets/images/Captura de tela de 2018-10-09 15-54-21.png
    domainEmitter: [object Object]
    domain: [object Object]
    domainThrown: false

I believe it is because of the lack of directories for which permission error was given. I tried to create them manually and nothing helped.

I tried to reinstall Ode, nothing either.

I tried to get back to version 3.4.0 of imagemmin, asked gifsicle, jpegtran-bin, optipng-bin packages, when the three installed packages the same error happens.

Version npm: 6.9.0

Gulp version:

CLI version: 2.2.0

Local version: 4.0.0

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.