Uncaught TypeError: Cannot read property 'prototype' of undefined Meteor-File Package

混江龙づ霸主 提交于 2019-12-23 05:27:54

问题


I have a problem when using this documentation: https://github.com/VeliovGroup/Meteor-Files/wiki/Image-Processing. This doc guides about create thumbnail images for pakage Meteor-File

I installed all need package like the guiding, but when I run code, it had a problem:

Uncaught TypeError: Cannot read property 'prototype' of undefined
    at patch (modules.js?hash=b849b729a9c5ee343b208254dca34d866ee59991:19084)
    at graceful-fs.js (modules.js?hash=b849b729a9c5ee343b208254dca34d866ee59991:18945)
    at fileEvaluate (modules-runtime.js?hash=8587d188e038b75ecd27ed2469a52b269e38fb62:343)
    at require (modules-runtime.js?hash=8587d188e038b75ecd27ed2469a52b269e38fb62:238)
    at index.js (modules.js?hash=b849b729a9c5ee343b208254dca34d866ee59991:16785)
    at fileEvaluate (modules-runtime.js?hash=8587d188e038b75ecd27ed2469a52b269e38fb62:343)
    at require (modules-runtime.js?hash=8587d188e038b75ecd27ed2469a52b269e38fb62:238)
    at index.js (modules.js?hash=b849b729a9c5ee343b208254dca34d866ee59991:16624)
    at fileEvaluate (modules-runtime.js?hash=8587d188e038b75ecd27ed2469a52b269e38fb62:343)
    at require (modules-runtime.js?hash=8587d188e038b75ecd27ed2469a52b269e38fb62:238)

I follow the trace, and found the prototype in here:

  var fs$ReadStream = fs.ReadStream                                                                                 
  ReadStream.prototype = Object.create(fs$ReadStream.prototype)                                                       
  ReadStream.prototype.open = ReadStream$open  

'fs' lib is using in here:

import fs from 'fs-extra';

Please help me!


回答1:


Maybe you should try with something like this ?

var fs$ReadStream = fs.ReadStream                                                                                 
fs.ReadStream.prototype = Object.create(fs$ReadStream.prototype)                                                       
fs.ReadStream.prototype.open = ReadStream$open  

Hope it helps.




回答2:


I worked around this problem by simply using the built-in node fs module instead of fs-extra. Have not had any problems so far.




回答3:


'fs' lib is available in server side. so just wrap these code in block:

if (Meteor.isServer()){
   //use fs lib
}

or switch code file to server 's folder. It will work fine!



来源:https://stackoverflow.com/questions/47938778/uncaught-typeerror-cannot-read-property-prototype-of-undefined-meteor-file-pa

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!