2012-10-01 73 views
1

讀取屬性「8」每當我試着在Node.js的使用PNG-JS,我得到這個奇怪的錯誤:PNG-JS:不能未定義

/home/anderson/node_modules/png-js/png-node.js:152 
     b1 = this.data[this.pos++] << 24; 
        ^
TypeError: Cannot read property '8' of undefined 
    at PNG.readUInt32 (/home/anderson/node_modules/png-js/png-node.js:152:21) 
    at new PNG (/home/anderson/node_modules/png-js/png-node.js:56:26) 
    at /home/anderson/node_modules/png-js/png-node.js:34:15 
    at [object Object].<anonymous> (fs.js:88:5) 
    at [object Object].emit (events.js:67:17) 
    at Object.oncomplete (fs.js:1059:12) 

這裏的生成此輸出方案:

var PNG = require('png-js'); 
PNG.decode('some.png', function(pixels) { 
    // pixels is a 1d array of decoded pixel data 
}); 

在過去,我已經能夠毫無困難地使用png-js模塊。這個模塊可能與我安裝的另一個node.js模塊衝突嗎?

回答

1

在這種特殊情況下,出現了錯誤消息,因爲名爲some.png的文件不在與node.js腳本相同的文件夾中。

+0

不錯!同樣的問題也發生在我身上......謝謝! –