imagemin / imagemin

Minify images seamlessly
MIT License
5.57k stars 259 forks source link

Error while trying to minify image #272

Open antoinecomp opened 6 years ago

antoinecomp commented 6 years ago

I am learning how to create a distribution folder that contains the files that can be implemented on a web server hosting your project. This distribution folder will be compiled from the files of your project using various NPM packages and scripts.

However when I try to execute the command npm run build and I have errors with imagemin img/* -o dist/img

The code is on Bitbucket

mike@mike-thinks:~/Bootstrap4/conFusion$ sudo npm run build

> confusion@1.0.0 build /home/mike/Bootstrap4/conFusion
> npm run clean && npm run imagemin && npm run copyfonts && npm run usemin

> confusion@1.0.0 clean /home/mike/Bootstrap4/conFusion
> rimraf dist

> confusion@1.0.0 imagemin /home/mike/Bootstrap4/conFusion
> imagemin img/* -o dist/img

Error: Error in file: img/logo.png

spawn /usr/local/lib/node_modules/imagemin-cli/node_modules/optipng-bin/vendor/optipng ENOENT
    at exports._errnoException (util.js:870:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32)
    at onErrorNT (internal/child_process.js:344:16)
    at nextTickCallbackWith2Args (node.js:441:9)
    at process._tickCallback (node.js:355:17)

npm ERR! Linux 4.10.0-42-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "imagemin"
npm ERR! node v4.2.6
npm ERR! npm  v3.5.2
npm ERR! code ELIFECYCLE
npm ERR! confusion@1.0.0 imagemin: `imagemin img/* -o dist/img`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the confusion@1.0.0 imagemin script 'imagemin img/* -o dist/img'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the confusion package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     imagemin img/* -o dist/img
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs confusion
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls confusion
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/mike/Bootstrap4/conFusion/npm-debug.log

npm ERR! Linux 4.10.0-42-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "build"
npm ERR! node v4.2.6
npm ERR! npm  v3.5.2
npm ERR! code ELIFECYCLE
npm ERR! confusion@1.0.0 build: `npm run clean && npm run imagemin && npm run copyfonts && npm run usemin`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the confusion@1.0.0 build script 'npm run clean && npm run imagemin && npm run copyfonts && npm run usemin'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the confusion package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     npm run clean && npm run imagemin && npm run copyfonts && npm run usemin
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs confusion
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls confusion
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/mike/Bootstrap4/conFusion/npm-debug.log

The file npm-debug.log is :

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/nodejs', '/usr/bin/npm', 'run', 'build' ]
2 info using npm@3.5.2
3 info using node@v4.2.6
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle confusion@1.0.0~prebuild: confusion@1.0.0
6 silly lifecycle confusion@1.0.0~prebuild: no script for prebuild, continuing
7 info lifecycle confusion@1.0.0~build: confusion@1.0.0
8 verbose lifecycle confusion@1.0.0~build: unsafe-perm in lifecycle true
9 verbose lifecycle confusion@1.0.0~build: PATH: /usr/share/npm/bin/node-gyp-bin:/home/mike/Bootstrap4/conFusion/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
10 verbose lifecycle confusion@1.0.0~build: CWD: /home/mike/Bootstrap4/conFusion
11 silly lifecycle confusion@1.0.0~build: Args: [ '-c',
11 silly lifecycle   'npm run clean && npm run imagemin && npm run copyfonts && npm run usemin' ]
12 silly lifecycle confusion@1.0.0~build: Returned: code: 1  signal: null
13 info lifecycle confusion@1.0.0~build: Failed to exec build script
14 verbose stack Error: confusion@1.0.0 build: `npm run clean && npm run imagemin && npm run copyfonts && npm run usemin`
14 verbose stack Exit status 1
14 verbose stack     at EventEmitter.<anonymous> (/usr/share/npm/lib/utils/lifecycle.js:232:16)
14 verbose stack     at emitTwo (events.js:87:13)
14 verbose stack     at EventEmitter.emit (events.js:172:7)
14 verbose stack     at ChildProcess.<anonymous> (/usr/share/npm/lib/utils/spawn.js:24:14)
14 verbose stack     at emitTwo (events.js:87:13)
14 verbose stack     at ChildProcess.emit (events.js:172:7)
14 verbose stack     at maybeClose (internal/child_process.js:821:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
15 verbose pkgid confusion@1.0.0
16 verbose cwd /home/mike/Bootstrap4/conFusion
17 error Linux 4.10.0-42-generic
18 error argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "build"
19 error node v4.2.6
20 error npm  v3.5.2
21 error code ELIFECYCLE
22 error confusion@1.0.0 build: `npm run clean && npm run imagemin && npm run copyfonts && npm run usemin`
22 error Exit status 1
23 error Failed at the confusion@1.0.0 build script 'npm run clean && npm run imagemin && npm run copyfonts && npm run usemin'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the confusion package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error     npm run clean && npm run imagemin && npm run copyfonts && npm run usemin
23 error You can get information on how to open an issue for this project with:
23 error     npm bugs confusion
23 error Or if that isn't available, you can get their info via:
23 error     npm owner ls confusion
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]

I would be very glad for any help. I am new to minifying

antoinecomp commented 6 years ago

I have now downloaded npm last version. I ran npm run build but I got two errors with confusion@1.0.0 imagemin script. and confusion@1.0.0 build script:

mike@mike-thinks:~/Bootstrap4/conFusion$ npm run build

> confusion@1.0.0 build /home/mike/Bootstrap4/conFusion
> npm run clean && npm run imagemin && npm run copyfonts && npm run usemin

> confusion@1.0.0 clean /home/mike/Bootstrap4/conFusion
> rimraf dist

> confusion@1.0.0 imagemin /home/mike/Bootstrap4/conFusion
> imagemin img/* -o dist/img

Error: Error in file: img/logo.png

spawn /usr/local/lib/node_modules/imagemin-cli/node_modules/optipng-bin/vendor/optipng ENOENT
    at _errnoException (util.js:1031:13)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:201:19)
    at onErrorNT (internal/child_process.js:389:16)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! confusion@1.0.0 imagemin: `imagemin img/* -o dist/img`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the confusion@1.0.0 imagemin 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!     /home/mike/.npm/_logs/2017-12-27T11_42_38_033Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! confusion@1.0.0 build: `npm run clean && npm run imagemin && npm run copyfonts && npm run usemin`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the confusion@1.0.0 build 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!     /home/mike/.npm/_logs/2017-12-27T11_42_38_103Z-debug.log

Here is the log for imagemin:imagemin img/* -o dist/img,2017-12-27T11_42_38_033Z-debug.log` :

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'imagemin' ]
2 info using npm@5.5.1
3 info using node@v9.2.1
4 verbose run-script [ 'preimagemin', 'imagemin', 'postimagemin' ]
5 info lifecycle confusion@1.0.0~preimagemin: confusion@1.0.0
6 info lifecycle confusion@1.0.0~imagemin: confusion@1.0.0
7 verbose lifecycle confusion@1.0.0~imagemin: unsafe-perm in lifecycle true
8 verbose lifecycle confusion@1.0.0~imagemin: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/home/mike/Bootstrap4/conFusion/node_modules/.bin:/usr/local/lib/node_modules/npm/bin/node-gyp-bin:/home/mike/Bootstrap4/conFusion/node_modules/.bin:/home/mike/bin:/home/mike/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin:/usr/lib/jvm/java-version/bin:/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java/bin:/usr/local/hadoop/bin
9 verbose lifecycle confusion@1.0.0~imagemin: CWD: /home/mike/Bootstrap4/conFusion
10 silly lifecycle confusion@1.0.0~imagemin: Args: [ '-c', 'imagemin img/* -o dist/img' ]
11 silly lifecycle confusion@1.0.0~imagemin: Returned: code: 1  signal: null
12 info lifecycle confusion@1.0.0~imagemin: Failed to exec imagemin script
13 verbose stack Error: confusion@1.0.0 imagemin: `imagemin img/* -o dist/img`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:280:16)
13 verbose stack     at EventEmitter.emit (events.js:159:13)
13 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:159:13)
13 verbose stack     at maybeClose (internal/child_process.js:943:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)
14 verbose pkgid confusion@1.0.0
15 verbose cwd /home/mike/Bootstrap4/conFusion
16 verbose Linux 4.10.0-42-generic
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "imagemin"
18 verbose node v9.2.1
19 verbose npm  v5.5.1
20 error code ELIFECYCLE
21 error errno 1
22 error confusion@1.0.0 imagemin: `imagemin img/* -o dist/img`
22 error Exit status 1
23 error Failed at the confusion@1.0.0 imagemin script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

And here is the one for confusion@1.0.0 build script, 2017-12-27T11_42_38_103Z-debug.log

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'build' ]
2 info using npm@5.5.1
3 info using node@v9.2.1
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle confusion@1.0.0~prebuild: confusion@1.0.0
6 info lifecycle confusion@1.0.0~build: confusion@1.0.0
7 verbose lifecycle confusion@1.0.0~build: unsafe-perm in lifecycle true
8 verbose lifecycle confusion@1.0.0~build: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/home/mike/Bootstrap4/conFusion/node_modules/.bin:/home/mike/bin:/home/mike/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin:/usr/lib/jvm/java-version/bin:/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java/bin:/usr/local/hadoop/bin
9 verbose lifecycle confusion@1.0.0~build: CWD: /home/mike/Bootstrap4/conFusion
10 silly lifecycle confusion@1.0.0~build: Args: [ '-c',
10 silly lifecycle   'npm run clean && npm run imagemin && npm run copyfonts && npm run usemin' ]
11 silly lifecycle confusion@1.0.0~build: Returned: code: 1  signal: null
12 info lifecycle confusion@1.0.0~build: Failed to exec build script
13 verbose stack Error: confusion@1.0.0 build: `npm run clean && npm run imagemin && npm run copyfonts && npm run usemin`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:280:16)
13 verbose stack     at EventEmitter.emit (events.js:159:13)
13 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:159:13)
13 verbose stack     at maybeClose (internal/child_process.js:943:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)
14 verbose pkgid confusion@1.0.0
15 verbose cwd /home/mike/Bootstrap4/conFusion
16 verbose Linux 4.10.0-42-generic
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "build"
18 verbose node v9.2.1
19 verbose npm  v5.5.1
20 error code ELIFECYCLE
21 error errno 1
22 error confusion@1.0.0 build: `npm run clean && npm run imagemin && npm run copyfonts && npm run usemin`
22 error Exit status 1
23 error Failed at the confusion@1.0.0 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
hTrap commented 5 years ago

use this in scripts "imagemin": "imagemin img/* --out-dir dist/img" also use npm install --save-dev imagemin imagemin-cli

charlesxu90 commented 4 years ago

@hTrap this doesn't solve the problem. Env: Win 10 cygwin.

AdminAbhi commented 4 years ago

@hTrap Thanks... that solved the problem