安装gulp-imagemin时出错

时间:2016-02-09 03:08:06

标签: npm gulp gulp-imagemin

当我尝试使用命令npm install gulp-imagemin --save-dev在bash中安装gulp-imagemin时,我收到了很多错误,如下所示。这是我第一次使用gulp(或构建工具)。我安装了其他几个插件并运行得很好。这是我见过的第一个错误。 我正在运行Windows Vista。 提前谢谢。

Dimitris (master) performance-optimization $ npm install --save-dev gulp-imagem
in
-
> gifsicle@3.0.3 postinstall c:\Users\Dimitris\documents\nanodegree\performance-
optimization\node_modules\gulp-imagemin\node_modules\imagemin\node_modules\image
min-gifsicle\node_modules\gifsicle
> node lib/install.js

module.js:338
    throw err;
          ^
Error: Cannot find module 'is-extglob'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (c:\Users\Dimitris\documents\nanodegree\performance-op
timization\node_modules\gulp-imagemin\node_modules\imagemin\node_modules\vinyl-f
s\node_modules\glob-stream\node_modules\glob-parent\node_modules\is-glob\index.j
s:8:17)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)

> optipng-bin@3.0.4 postinstall c:\Users\Dimitris\documents\nanodegree\performan
ce-optimization\node_modules\gulp-imagemin\node_modules\imagemin\node_modules\im
agemin-optipng\node_modules\optipng-bin
> node lib/install.js

module.js:338
    throw err;
          ^
Error: Cannot find module 'is-extglob'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (c:\Users\Dimitris\documents\nanodegree\performance-op
timization\node_modules\gulp-imagemin\node_modules\imagemin\node_modules\vinyl-f
s\node_modules\glob-stream\node_modules\glob-parent\node_modules\is-glob\index.j
s:8:17)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
npm WARN optional dep failed, continuing imagemin-gifsicle@4.2.0

> jpegtran-bin@3.0.6 postinstall c:\Users\Dimitris\documents\nanodegree\performa
nce-optimization\node_modules\gulp-imagemin\node_modules\imagemin\node_modules\i
magemin-jpegtran\node_modules\jpegtran-bin
> node lib/install.js

module.js:338
    throw err;
          ^
Error: Cannot find module 'is-extglob'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (c:\Users\Dimitris\documents\nanodegree\performance-op
timization\node_modules\gulp-imagemin\node_modules\imagemin\node_modules\vinyl-f
s\node_modules\glob-stream\node_modules\glob-parent\node_modules\is-glob\index.j
s:8:17)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
npm WARN optional dep failed, continuing imagemin-optipng@4.3.0
npm WARN optional dep failed, continuing imagemin-jpegtran@4.3.2
npm ERR! Windows_NT 6.0.6002
npm ERR! argv "c:\\Program Files\\nodejs\\node.exe" "c:\\Program Files\\nodejs\\
node_modules\\npm\\bin\\npm-cli.js" "install" "--save-dev" "gulp-imagemin"
npm ERR! node v0.12.7
npm ERR! npm  v2.11.3
npm ERR! path C:\Users\Dimitris\AppData\Roaming\npm-cache\is-extglob\1.0.0\packa
ge\package.json
npm ERR! code EPERM
npm ERR! errno -4048

npm ERR! Error: EPERM, rename 'C:\Users\Dimitris\AppData\Roaming\npm-cache\is-ex
tglob\1.0.0\package\package.json'
npm ERR!     at Error (native)
npm ERR!  { [Error: EPERM, rename 'C:\Users\Dimitris\AppData\Roaming\npm-cache\i
s-extglob\1.0.0\package\package.json']
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   path: 'C:\\Users\\Dimitris\\AppData\\Roaming\\npm-cache\\is-extglob\\
1.0.0\\package\\package.json',
npm ERR!   parent: 'is-glob' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     c:\Users\Dimitris\documents\nanodegree\performance-optimization\npm
-debug.log
/c/Program Files/nodejs/npm: line 14:  7708 Signal 112              (core dumped
) "$basedir/node.exe" "$basedir/node_modules/npm/bin/npm-cli.js" "$@"

1 个答案:

答案 0 :(得分:0)

npm install --save-dev gulp-imagem更改为sudo npm install --save-dev gulp-imagem

Kylin:zhaofudao jcl$ npm install gulp-imagemin --save-dev
npm ERR! Darwin 15.3.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "gulp-imagemin" "--save-dev"
npm ERR! node v4.4.3
npm ERR! npm  v2.15.1
npm ERR! path /Applications/XAMPP/xamppfiles/htdocs/zhaofudao/node_modules/gulp-imagemin/node_modules/.bin/pretty-bytes
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall unlink

npm ERR! Error: EACCES: permission denied, unlink '/Applications/XAMPP/xamppfiles/htdocs/zhaofudao/node_modules/gulp-imagemin/node_modules/.bin/pretty-bytes'
npm ERR!     at Error (native)
npm ERR!  { [Error: EACCES: permission denied, unlink '/Applications/XAMPP/xamppfiles/htdocs/zhaofudao/node_modules/gulp-imagemin/node_modules/.bin/pretty-bytes']
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'unlink',
npm ERR!   path: '/Applications/XAMPP/xamppfiles/htdocs/zhaofudao/node_modules/gulp-imagemin/node_modules/.bin/pretty-bytes' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.
npm ERR! error rolling back Error: EACCES: permission denied, unlink '/Applications/XAMPP/xamppfiles/htdocs/zhaofudao/node_modules/gulp-imagemin/node_modules/.bin/pretty-bytes'
npm ERR! error rolling back     at Error (native)
npm ERR! error rolling back  { [Error: EACCES: permission denied, unlink '/Applications/XAMPP/xamppfiles/htdocs/zhaofudao/node_modules/gulp-imagemin/node_modules/.bin/pretty-bytes']
npm ERR! error rolling back   errno: -13,
npm ERR! error rolling back   code: 'EACCES',
npm ERR! error rolling back   syscall: 'unlink',
npm ERR! error rolling back   path: '/Applications/XAMPP/xamppfiles/htdocs/zhaofudao/node_modules/gulp-imagemin/node_modules/.bin/pretty-bytes' }

npm ERR! Please include the following file with any support request:
npm ERR!     /Applications/XAMPP/xamppfiles/htdocs/zhaofudao/npm-debug.log
Kylin:zhaofudao jcl$ sudo npm install gulp-imagemin --save-dev
Password:
gulp-imagemin@2.4.0 node_modules/gulp-imagemin
├── object-assign@4.0.1
├── chalk@1.1.3 (escape-string-regexp@1.0.5, supports-color@2.0.0, ansi-styles@2.2.1, strip-ansi@3.0.1, has-ansi@2.0.0)
├── plur@2.1.2 (irregular-plurals@1.1.0)
├── through2-concurrent@1.1.0 (through2@2.0.1)
├── pretty-bytes@2.0.1 (get-stdin@4.0.1, number-is-nan@1.0.0, meow@3.7.0)
├── gulp-util@3.0.7 (array-differ@1.0.0, array-uniq@1.0.2, lodash._reevaluate@3.0.0, beeper@1.1.0, lodash._reescape@3.0.0, lodash._reinterpolate@3.0.0, object-assign@3.0.0, replace-ext@0.0.1, minimist@1.2.0, has-gulplog@0.1.0, vinyl@0.5.3, gulplog@1.0.0, through2@2.0.1, lodash.template@3.6.2, multipipe@0.1.2, fancy-log@1.2.0, dateformat@1.0.12)
└── imagemin@4.0.0 (optional@0.1.3, buffer-to-vinyl@1.1.0, stream-combiner2@1.1.1, concat-stream@1.5.1, readable-stream@2.1.0, vinyl-fs@2.4.3, imagemin-svgo@4.2.1)

enter image description here