Skip to content Skip to sidebar Skip to footer

Error: Uncaughtexception: Primordials Is Not Defined

I installed aws-s3-zipper using npm, after that, I am getting this error. This is my code: AWS = require('aws-sdk'); var S3Zipper = require('aws-s3-zipper'); function zipFolderOnS

Solution 1:

aws-s3-zipper depends on s3node-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.

According to this graceful-fs v4.2.2 is known to work with node 12...

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.

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:

  1. first update your 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.

  2. 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 packagevar S3Zipper = require("./aws-s3-zipper");
  1. finally, fix the dependency issue in ./aws-s3-zipper.js that you copied down:
var assert = require('assert');
var archiver = require('archiver');
varasync = require('async');
varAWS = 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.

Solution 2:

Update the dependency in s3 from graceful-fs": "~3.0.5", to "graceful-fs": "^4.2.6",

it resolved for me

Solution 3:

From this issue - https://github.com/andrewrk/node-s3-client/issues/236

Add the following to your package.json file so s3 can work with node > 12.

"resolutions":{"graceful-fs":"4.x.x"},

Post a Comment for "Error: Uncaughtexception: Primordials Is Not Defined"