andrewrk / node-s3-client

high level amazon s3 client for node.js
MIT License
1k stars 303 forks source link

S3 module not working on node 12 #228

Open shkedi opened 4 years ago

shkedi commented 4 years ago

I am running node version 12.13.0 (LTS) and using the latest s3 module (4.4.0) the module using with an old version of graceful-fs that was broken in node 12. I am getting this error ReferenceError: primordials is not defined at fs.js:27:26 at req_ (/app/node_modules/natives/index.js:143:24) at Object.req [as require] (/app/node_modules/natives/index.js:55:10) at Object. (/app/node_modules/s3/node_modules/graceful-fs/fs.js:1:37) at Module._compile (internal/modules/cjs/loader.js:956:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10) at Module.load (internal/modules/cjs/loader.js:812:32) at Function.Module._load (internal/modules/cjs/loader.js:724:14) at Module.require (internal/modules/cjs/loader.js:849:19) at require (internal/modules/cjs/helpers.js:74:18) at Object. (/app/node_modules/s3/node_modules/graceful-fs/graceful-fs.js:3:27) at Module._compile (internal/modules/cjs/loader.js:956:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10) at Module.load (internal/modules/cjs/loader.js:812:32) at Function.Module._load (internal/modules/cjs/loader.js:724:14) at Module.require (internal/modules/cjs/loader.js:849:19) at require (internal/modules/cjs/helpers.js:74:18)
at Object. (/app/node_modules/s3/lib/index.js:3:10) at Module._compile (internal/modules/cjs/loader.js:956:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10) at Module.load (internal/modules/cjs/loader.js:812:32) at Function.Module._load (internal/modules/cjs/loader.js:724:14) at Module.require (internal/modules/cjs/loader.js:849:19) at require (internal/modules/cjs/helpers.js:74:18)

manimoto commented 4 years ago

you need to update graceful-fs package of s3 to updated version it will work then. i had the same issue.

shkedi commented 4 years ago

@manimoto Thanks for your answer. I can't change manually the graceful-fs' version, it is in production and I can't change manually the package-lock. It seems the module wasn't changed ~5 years, I think the solution will be to move to aws-sdk npm package

sonicoder86 commented 4 years ago

Use the fork of this repo https://github.com/auth0/node-s3-client

shkedi commented 4 years ago

Thanks @blacksonic

RajaBellebon commented 4 years ago

I was trying to use the fork to replace our currently s3-cli that is calling s3 but faced weird issues where it seems that my files are uploaded but I can't access them..

Anyway, do you know if a proper fix or a new release with the fork will be done soon?

Thanks in advance

MattBro commented 4 years ago

Looks like there was a problem publishing the 4.4.0 version of this s3 client. The source code has "graceful-fs": "~4.1.4",, but the package.json at https://registry.npmjs.org/s3/-/s3-4.4.0.tgz has "graceful-fs": "~3.0.5",

SyedSaimAliZaidi commented 4 years ago

you need to update graceful-fs package of s3 to updated version it will work then. i had the same issue.

i have updated the package but the issue is still there. [nodemon] starting node index.js fs.js:35 } = primordials; ^

ReferenceError: primordials is not defined at fs.js:35:5 at req_ (C:\Users\Venom\Desktop\test\node_modules\natives\index.js:143:24) at Object.req [as require] (C:\Users\Venom\Desktop\test\node_modules\natives\index.js:55:10) at Object. (C:\Users\Venom\Desktop\test\node_modules\s3\node_modules\graceful-fs\fs.js:1:37) at Module._compile (internal/modules/cjs/loader.js:1158:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10) at Module.load (internal/modules/cjs/loader.js:1002:32)
at Function.Module._load (internal/modules/cjs/loader.js:901:14) at Module.require (internal/modules/cjs/loader.js:1044:19)
at require (internal/modules/cjs/helpers.js:77:18) [nodemon] app crashed - waiting for file changes before starting...

brainlessboy commented 4 years ago

same her, node 12.18.0 breaks, i found this which solves the problem by forcing the graceful-fs to 4.x using npm-shrinkwrap.json, but requires to manualy regenerate that file every time npm i is executed, if not it breaks again. so how do you update the graceful-fs in the s3 package the right way?

RajaBellebon commented 4 years ago

Hello @brainlessboy ,

You can use the resolutions field in package.json and force the version there.

Something like this

"resolutions": {
.....
graceful-fs": "4.x.x"
}
brainlessboy commented 4 years ago

@RajaBellebon many thanks!

mayurtikundi12 commented 4 years ago

n production and I can't change manually the you can check this module , just change the module this is the updated one https://www.npmjs.com/package/s3abstraction

andersryanc commented 3 years ago

@RajaBellebon your solution using resolutions doesn't seem to work for me. Are you using yarn? According to this StackOverflow post resolutions isn't supported by node directly ... If you are using Node, which version? I'm currently on 12.

@blacksonic thanks for the suggestion, I was able to get things working on my end using the @auth0/s3 fork. Seems like the fact that they updated graceful-fs in there did the trick!

Is there any timeline to update this package properly?

ncnipunchawla commented 3 years ago

I am using https://www.npmjs.com/package/s3-node for Node 14

npm install s3-node