操作系统:window和linux都会遇到
软件环境:v20.10.0的Nodejs
1、前端代码如下:
2、后端Nodejs
2.1、注册接口
2.2、上传接口
其中memoryUpload方法代码如下:
3、用页面上传文件
查看具体报错原因:
TypeError: source.on is not a function
at Function.create (D:\weichai\nodebase\app\sugar\node_modules\delayed-stream\lib\delayed_stream.js:33:10)
at FormData.append (D:\weichai\nodebase\app\sugar\node_modules\combined-stream\lib\combined_stream.js:45:37)
at FormData.append (D:\weichai\nodebase\app\sugar\node_modules\form-data\lib\form_data.js:74:3)
at D:\weichai\nodebase\app\sugar\action\file.js:108:22
at step (D:\weichai\nodebase\app\sugar\node_modules\tslib\tslib.js:143:27)
at Object.next (D:\weichai\nodebase\app\sugar\node_modules\tslib\tslib.js:124:57)
at fulfilled (D:\weichai\nodebase\app\sugar\node_modules\tslib\tslib.js:114:62)
at bound (node:domain:432:15)
at runBound (node:domain:443:12)
at tryCatcher (D:\weichai\nodebase\node_modules\bluebird\js\release\util.js:16:23)
at Promise._settlePromiseFromHandler (D:\weichai\nodebase\node_modules\bluebird\js\release\promise.js:547:31)
at Promise._settlePromise (D:\weichai\nodebase\node_modules\bluebird\js\release\promise.js:604:18)
at Promise._settlePromise0 (D:\weichai\nodebase\node_modules\bluebird\js\release\promise.js:649:10)
at Promise._settlePromises (D:\weichai\nodebase\node_modules\bluebird\js\release\promise.js:729:18)
at _drainQueueStep (D:\weichai\nodebase\node_modules\bluebird\js\release\async.js:93:12)
at _drainQueue (D:\weichai\nodebase\node_modules\bluebird\js\release\async.js:86:9)
at Async._drainQueues (D:\weichai\nodebase\node_modules\bluebird\js\release\async.js:102:5)
at Async.drainQueues [as _onImmediate] (D:\weichai\nodebase\node_modules\bluebird\js\release\async.js:15:14)
at process.processImmediate (node:internal/timers:478:21)
at process.topLevelDomainCallback (node:domain:160:15)
at process.callbackTrampoline (node:internal/async_hooks:128:24)
请问可以怎么解决这个问题呢?