错误:uncaughtException:未定义原始 [英] error: uncaughtException: primordials is not defined
问题描述
我使用 npm
安装了 aws-s3-zipper
,之后,我收到此错误.
I installed aws-s3-zipper
using npm
, after that, I am getting this error.
这是我的代码:
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
依赖于 s3
node-s3-client 依赖于 graceful-fs
(s3@4.4.0 当前包含的版本)与节点 v12 及更高版本存在问题/不兼容.
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.
根据 此 优雅-fs v4.2.2 已知可与节点 12 一起使用...
According to this graceful-fs v4.2.2 is known to work with node 12...
真正需要发生的是node-s3-client 需要更新他们对graceful-fs 的依赖.已经有一个 open github issue 对此,有人建议使用 @auth0/s3.
What really needs to happen, is that node-s3-client needs to update their dependency of graceful-fs. There is already an open github issue for this, in which someone suggested to use @auth0/s3.
因此,您可以尝试让 aws-s3-zipper
切换到使用它,直到官方软件包更新...或者... aws-s3-zipper
只是一个文件,因此您也可以将其复制到您的项目中.
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.
这是我能够开始工作的内容:
Here is what I was able to get working:
- 首先更新你的 deps
npm uninstall aws-s3-zipper
npm install @auth0/s3 archiver
复制index.js 源代码 从 aws-s3-zipper 到项目中的一个新文件,例如
./aws-s3-zipper.js
.
copy the index.js source code from aws-s3-zipper into a new file in your project, like
./aws-s3-zipper.js
.
更新文件中的 require 语句:
update your require statements in your file:
// 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
中的依赖问题:
- finally, fix the dependency issue in
./aws-s3-zipper.js
that you copied down:
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
我在 中评论了这个 GitHub 问题aws-s3-zipper
repo 认为他们可能有同样的问题,看看他们是否可能暂时切换到 @auth0/s3
.
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.
这篇关于错误:uncaughtException:未定义原始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!