gpt4 book ai didi

node.js - 错误 : Cannot find module '@aws-sdk/abort-controller'

转载 作者:行者123 更新时间:2023-12-05 08:45:28 25 4
gpt4 key购买 nike

我正在尝试使用 multer 和 multer-s3 将图像上传到服务器。但我无法声明 multer-s3 包。显示

Error: Cannot find module '@aws-sdk/abort-controller'

这是声明代码

const multers3 = require('multer-s3');

错误

node:internal/modules/cjs/loader:936
throw err;
^

Error: Cannot find module '@aws-sdk/abort-controller'
Require stack:
- /Users/venkat/ecom_server/node_modules/@aws-sdk/lib-storage/dist-cjs/Upload.js
- /Users/venkat/ecom_server/node_modules/@aws-sdk/lib-storage/dist-cjs/index.js
- /Users/venkat/ecom_server/node_modules/multer-s3/index.js
- /Users/venkat/ecom_server/index.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/Users/venkat/ecom_server/node_modules/@aws-sdk/lib-storage/dist-cjs/Upload.js:4:28)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Users/venkat/ecom_server/node_modules/@aws-sdk/lib-storage/dist-cjs/Upload.js',
'/Users/venkat/ecom_server/node_modules/@aws-sdk/lib-storage/dist-cjs/index.js',
'/Users/venkat/ecom_server/node_modules/multer-s3/index.js',
'/Users/venkat/ecom_server/index.js'
]
}

Node 版本:v16.15.1

最佳答案

我遇到了类似的问题。正是来自 official npm documentation of multer-s3 的这一行解决了这个问题:

enter image description here

简而言之,如果您使用的是 aws-sdk 的 v2,请使用 multer-s3 的 2.x.x 版本,对于 aws-sdk 的 v3,请使用 multer-s3 的 3.x.x。

关于node.js - 错误 : Cannot find module '@aws-sdk/abort-controller' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72696822/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com