简体   繁体   English

错误:uncaughtException:未定义原始

[英]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:这是我能够开始工作的内容:

  1. first update your deps首先更新你的 deps
npm uninstall aws-s3-zipper
npm install @auth0/s3 archiver
  1. 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

  2. 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");
  1. finally, fix the dependency issue in ./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.

相关问题 NodeJS - 未捕获的 ReferenceError:原始值未定义 - NodeJS - Uncaught ReferenceError: primordials is not defined npm ReferenceError: primordials is not defined (node.js) - npm ReferenceError: primordials is not defined (node.js) Jestjs - uncaughtException:未定义描述\\nReferenceError:未定义描述 - Jestjs - uncaughtException: describe is not defined\nReferenceError: describe is not defined uncaughtException 然后 appendFile 出错会导致问题吗? NodeJs - uncaughtException then appendFile on error will this cause problems? NodeJs 绑定uncaughtException事件以处理回调nodejs中发生的错误的最佳实践? - is it best practice to bind uncaughtException event to handle error occurs in callback nodejs? Appium错误:uncaughtException:无法读取null的属性“ executeAtom” - Appium error: uncaughtException: Cannot read property 'executeAtom' of null 如何解决 nodejs uncaughtException: Connection already Release 错误和 MaxListenersExceededWarning? - How to solve nodejs uncaughtException: Connection already released error and MaxListenersExceededWarning? 发射战神发射的ERR! uncaughtException错误:生成cmd ENOENT - Launch ares-launch ERR! uncaughtException Error: spawn cmd ENOENT fs.createReadStream 错误; uncaughtException: ENOENT: 没有这样的文件或目录 - fs.createReadStream error; uncaughtException: ENOENT: no such file or directory Node.js - 比 process.on('uncaughtException', fn) 更好的错误处理? - Node.js - better error handling than process.on('uncaughtException', fn)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM