由于错误,npm启动失败:无法找到模块'color-thief'

时间:2016-03-21 21:59:47

标签: node.js canvas npm windows-10

我正在尝试运行npm start(或node bin\www)来运行克隆的github项目。 该项目使用的是canvas,因为我在Windows 10上,所以我必须安装GTK库才能npm install --msvs_version=2013

好像npm install

一切顺利
> canvas@1.2.11 install C:\Users\ramtin\trooptraining\troop\troop-asset-server\node_modules\color-thief\node_modules\canvas
> node-gyp rebuild


C:\Users\ramtin\trooptraining\troop\troop-asset-server\node_modules\color-thief\node_modules\canvas {git}{hg}
{lamb} if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node  rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  Canvas.cc
  CanvasGradient.cc
  CanvasPattern.cc
  CanvasRenderingContext2d.cc
  color.cc
  Image.cc
  ImageData.cc
  init.cc
     Creating library C:\Users\ramtin\trooptraining\troop\troop-asset-server\node_modules\color-thief\node_mod
  ules\canvas\build\Release\canvas.lib and object C:\Users\ramtin\trooptraining\troop\troop-asset-server\node_
  modules\color-thief\node_modules\canvas\build\Release\canvas.exp
  Generating code
  Finished generating code
  canvas.vcxproj -> C:\Users\ramtin\trooptraining\troop\troop-asset-server\node_modules\color-thief\node_modul
  es\canvas\build\Release\\canvas.node
  Copying C:/GTK/bin/libcairo-2.dll to C:\Users\ramtin\trooptraining\troop\troop-asset-server\node_modules\col
  or-thief\node_modules\canvas\build\Release\\libcairo-2.dll
          1 file(s) copied.
  Copying C:/GTK/bin/libfontconfig-1.dll to C:\Users\ramtin\trooptraining\troop\troop-asset-server\node_module
  s\color-thief\node_modules\canvas\build\Release\\libfontconfig-1.dll
          1 file(s) copied.
  Copying C:/GTK/bin/libexpat-1.dll to C:\Users\ramtin\trooptraining\troop\troop-asset-server\node_modules\col
  or-thief\node_modules\canvas\build\Release\\libexpat-1.dll
          1 file(s) copied.
  Copying C:/GTK/bin/libfreetype-6.dll to C:\Users\ramtin\trooptraining\troop\troop-asset-server\node_modules\
  color-thief\node_modules\canvas\build\Release\\libfreetype-6.dll
          1 file(s) copied.
  Copying C:/GTK/bin/libpng14-14.dll to C:\Users\ramtin\trooptraining\troop\troop-asset-server\node_modules\co
  lor-thief\node_modules\canvas\build\Release\\libpng14-14.dll
          1 file(s) copied.
  Copying C:/GTK/bin/zlib1.dll to C:\Users\ramtin\trooptraining\troop\troop-asset-server\node_modules\color-th
  ief\node_modules\canvas\build\Release\\zlib1.dll
          1 file(s) copied.

> dtrace-provider@0.6.0 install C:\Users\ramtin\trooptraining\troop\troop-asset-server\node_modules\dtrace-provider
> node scripts/install.js

color-thief@2.2.1 node_modules\color-thief
└── canvas@1.2.11

这是我运行npm start时得到的日志:

> troop-asset-server@0.0.0 start C:\Users\ramtin\trooptraining\troop\troop-asset-server
> node ./bin/www

module.js:355
  Module._extensions[extension](this, filename);
                               ^
Error: The specified module could not be found.
C:\Users\ramtin\trooptraining\troop\troop-asset-server\node_modules\color-thief\node_modules\canvas\build\Release\canvas.node
    at Error (native)
    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)
    at Object.<anonymous> (C:\Users\ramtin\trooptraining\troop\troop-asset-server\node_modules\color-thief\node_modules\canvas\lib\bindings.js:2:18)
    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)

npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v0.12.7
npm ERR! npm  v2.11.3
npm ERR! code ELIFECYCLE
npm ERR! troop-asset-server@0.0.0 start: `node ./bin/www`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the troop-asset-server@0.0.0 start script 'node ./bin/www'.
npm ERR! This is most likely a problem with the troop-asset-server package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node ./bin/www
npm ERR! You can get their info via:
npm ERR!     npm owner ls troop-asset-server
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\ramtin\trooptraining\troop\troop-asset-server\npm-debug.log

我正在运行Windows 10 x64,节点v0.12.7(不允许升级),npm v2.11.3,node-gyp v2.0.1,MSVS 2015社区,MSC ++ 2013&amp; 2015(x86和x64)。

如何解决此问题?

1 个答案:

答案 0 :(得分:0)

必须将C:\GTK\bin中的所有dll和IEShims.dll中的C:\Program Files (x86)\Internet Explorer\复制到..\node_modules\color-thief\node_modules\canvas\build\Release\

还需要通过安装程序为Windows安装imagemagick并添加PATH环境变量的路径。

现在一切正常......