2014-10-03 42 views
0

在安裝Maverick之前,我的應用運行良好。在安裝Maverick後,當我在終端中鍵入nodemon app.js時,它不再起作用,因此我重新安裝了節點,然後 npm uninstall nodemon後跟npm install nodemon重新安裝它。這工作得很好,現在nodemon工作。不幸的是,現在我有一個我無法解決的新bug。當我的應用程序上傳圖片,我得到更新到Maverick後,我的節點模塊不再工作

TypeError: Cannot read property 'width' of undefined

 var gm = require('gm').subClass({ imageMagick: true }); 
     gm(target_path).size(function (err, size) {//shrinks and replaces large images 
      if (size.width > 700 || size.height > 700) { 
      gm(target_path).scale(700, 700).autoOrient().write(target_path, function (err) { 
       if (!err) console.log('shrunk! '); 
      }); 
      } 
     }); 

如果我註釋掉,然後只加載了圖像的頁面,然後我得到

Error: spawn ENOENT 
    at errnoException (child_process.js:1001:11) 
    at Process.ChildProcess._handle.onexit (child_process.js:792:34) 
2 Oct 17:30:21 - [nodemon] app crashed - waiting for file changes before starting... 

我已經卸載和resinstalled fs,gm,imagemagick,jquery,以及幾乎所有我沒有成功的模塊。我在usr/local/lib/node_modules 以及我的項目中的node_modules目錄中減去以下節點和npm中的以下內容。

$ ls 
    bcrypt-nodejs consolidate express  fs  gm  imagemagick jquery  mongodb  node-fs  nodemon  npm 

仍然得到這樣的:

/Users/Squirrel/Documents/Code/Memry/Memry_11-8/routes/content.js:605 
        if (size.width > 700 || size.height > 700) { 
         ^
TypeError: Cannot read property 'width' of undefined 
    at gm.<anonymous> (/Users/Squirrel/Documents/Code/Memry/Memry_11-8/routes/content.js:605:15) 
    at gm.emit (events.js:106:17) 
    at gm.<anonymous> (/Users/Squirrel/Documents/Code/Memry/Memry_11-8/node_modules/gm/lib/getters.js:70:16) 
    at cb (/Users/Squirrel/Documents/Code/Memry/Memry_11-8/node_modules/gm/lib/command.js:265:16) 
    at ChildProcess._spawn.proc.on.onExit (/Users/Squirrel/Documents/Code/Memry/Memry_11-8/node_modules/gm/lib/command.js:247:9) 
    at ChildProcess.emit (events.js:98:17) 
    at maybeClose (child_process.js:756:16) 
    at Socket.<anonymous> (child_process.js:969:11) 
    at Socket.emit (events.js:95:17) 
    at Pipe.close (net.js:465:12) 
3 Oct 11:58:43 - [nodemon] app crashed - waiting for file changes before starting.. 
+1

你有沒有在你的系統上安裝graphicsmagic? 'gm'模塊只是命令行二進制文件的一個包裝,所以看起來像命令行二進制文件不再安裝。 – mscdex 2014-10-03 14:49:23

+0

@mscdex我不確定。我如何檢查和/或安裝? – Squirrl 2014-10-03 14:54:41

+0

命令行二進制文件僅稱爲'gm',因此請嘗試在終端窗口中鍵入並查看返回的內容。 – mscdex 2014-10-03 15:04:05

回答

1

GraphicsMagick工具似乎已經在升級過程中被卸載,所以你需要重新安裝它爲gm節點模塊的工作,因爲它只是一個簡單的包裝圍繞命令行二進制gm

要安裝GraphicsMagick工具的系統庫和命令行實用工具,這裏有一些選擇:

  • 通過homebrew與安裝:port install graphicsmagick

  • brew install graphicsmagick

  • 通過macports與安裝Download,編譯並手動安裝GM。

+0

so'npm uninstall gm' then then'npm install gm'? – Squirrl 2014-10-03 15:06:34

+0

它看起來像我得到'-bash:命令未找到'爲每個模塊除了nodemon這是唯一一個工作 – Squirrl 2014-10-03 15:08:05

+1

不,你必須再次安裝GraphicsMagick軟件。無論你是從homebrew,macports還是編譯和安裝都可以做到這一點。 – mscdex 2014-10-03 15:08:09

相關問題