[英]error: uncaughtException: primordials is not defined
I installed aws-s3-zipper
using npm
, after that, I am getting this error.我使用
npm
安装了aws-s3-zipper
,之后,我收到此错误。
This is my code:这是我的代码:
AWS = require("aws-sdk");
var S3Zipper = require("aws-s3-zipper");
function zipFolderOnS3() {
var zipper = new S3Zipper(config);
return new Promise((resolve, reject) => {
var config = {
accessKeyId: process.env.ACCESS_KEY_ID,
secretAccessKey: process.env.SECRET_ACCESS_KEY,
region: process.env.REGION,
bucket: process.env.BUCKET_NAME
};
var zipper = new S3Zipper(config);
try {
zipper.zipToS3FileFragments({
s3FolderName: "Documents"
, MaxFileCount: 50
//, startKey: ‘keyOfLastFileIZipped' // optional
, S3ZipFileName: "Documents.zip",
recursive: true
}, function (err, result) {
if (err) {
console.error(err);
}
else {
console.error("File uploaded on s3");
}
});
} catch (e) {
console.log(e)
}
});
}
module.exports = {
zipFolderOnS3
};
aws-s3-zipper
depends on s3
node-s3-client which has a dependency of graceful-fs
which (the version currently included by s3@4.4.0) has issues/incompatibilities with node v12 and above. aws-s3-zipper
依赖于s3
node-s3-client ,它依赖于graceful-fs
(s3@4.4.0 当前包含的版本)与节点 v12 及更高版本存在问题/不兼容。
According to this graceful-fs v4.2.2 is known to work with node 12...根据此优雅-fs v4.2.2 已知可与节点 12 一起使用...
What really needs to happen, is that node-s3-client needs to update their dependency of graceful-fs.真正需要发生的是, node-s3-client需要更新他们对graceful-fs 的依赖。 There is already an open github issue for this, in which someone suggested to use @auth0/s3 .
已经有一个open github issue为此,有人建议使用@auth0/s3 。
So, you could either try and get aws-s3-zipper
to switch to using that until the official package is updated... OR... aws-s3-zipper
is only a single file, so you could also just copy in that to your project.所以,你可以尝试让
aws-s3-zipper
切换到使用它,直到官方包更新......或者...... aws-s3-zipper
只是一个文件,所以你也可以复制进去到您的项目。
Here is what I was able to get working:这是我能够开始工作的内容:
npm uninstall aws-s3-zipper
npm install @auth0/s3 archiver
copy the index.js source code from aws-s3-zipper into a new file in your project, like ./aws-s3-zipper.js
.将index.js 源代码从 aws-s3-zipper 复制到项目中的新文件中,例如
./aws-s3-zipper.js
。
update your require statements in your file:更新文件中的 require 语句:
// you can remove the AWS require as it's not actually used at all here
// AWS = require("aws-sdk");
// make this a relative path instead of including the package
var S3Zipper = require("./aws-s3-zipper");
./aws-s3-zipper.js
that you copied down:./aws-s3-zipper.js
中的依赖问题:var assert = require('assert');
var archiver = require('archiver');
var async = require('async');
var AWS = require('aws-sdk');
var fs = require('fs');
// change `s3` to `@auth0/s3`
var s3 = require('@auth0/s3');
// ... the rest of the package
I commented on this GitHub issue in the aws-s3-zipper
repo thinking they might be having the same issue and to see if they might switch to @auth0/s3
for the time being.我在
aws-s3-zipper
repo 中评论了这个 GitHub 问题,认为他们可能有同样的问题,看看他们是否可能@auth0/s3
切换到@auth0/s3
。
Update the dependency in s3 from graceful-fs": "~3.0.5",
to "graceful-fs": "^4.2.6",
将s3中的依赖从
graceful-fs": "~3.0.5",
为"graceful-fs": "^4.2.6",
it resolved for me它为我解决了
From this issue - https://github.com/andrewrk/node-s3-client/issues/236从这个问题 - https://github.com/andrewrk/node-s3-client/issues/236
Add the following to your package.json file so s3 can work with node > 12.将以下内容添加到您的 package.json 文件中,以便 s3 可以使用 node > 12。
"resolutions": {
"graceful-fs": "4.x.x"
},
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.