不能npm安装'gulp-imagemin'

时间:2016-06-16 22:44:19

标签: node.js npm gulp gulp-imagemin

在新的debian jessie ec2实例上,我执行以下操作:

  • sudo apt-get update
  • sudo apt-get install curl -y
  • curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
  • sudo apt-get install -y nodejs
  • mkdir / tmp / real_node_modules
  • ln -s / tmp / real_node_modules node_modules
  • npm install'gulp-imagemin'

然后我收到此错误:

> optipng-bin@3.1.2 postinstall /home/admin/node_modules/optipng-bin
> node lib/install.js

module.js:442
    throw err;
    ^

Error: Cannot find module 'bin-build'
    at Function.Module._resolveFilename (module.js:440:15)
    at Function.Module._load (module.js:388:25)
    at Module.require (module.js:468:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/tmp/real_node_modules/optipng-bin/lib/install.js:3:16)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
npm WARN install:optipng-bin@3.1.2 optipng-bin@3.1.2 postinstall: `node lib/install.js`
npm WARN install:optipng-bin@3.1.2 Exit status 1

> jpegtran-bin@3.0.6 postinstall /home/admin/node_modules/jpegtran-bin
> node lib/install.js

module.js:442
    throw err;
    ^

Error: Cannot find module 'bin-build'
    at Function.Module._resolveFilename (module.js:440:15)
    at Function.Module._load (module.js:388:25)
    at Module.require (module.js:468:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/tmp/real_node_modules/jpegtran-bin/lib/install.js:4:16)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
npm WARN install:jpegtran-bin@3.0.6 jpegtran-bin@3.0.6 postinstall: `node lib/install.js`
npm WARN install:jpegtran-bin@3.0.6 Exit status 1

不言而喻,没有符号链接的节点模块文件夹就能正常工作,但是我想弄清楚的是,如果你有一个符号链接的节点模块文件夹,它们就不起作用。

1 个答案:

答案 0 :(得分:0)

这是npm版本3.9.3中的错误。

修复正在改变“curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - ”to to curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash - “

编辑:我现在正在学习,不幸的是,npm 2.15.5也有类似的问题。