aws-sdk-js-v3: Module not found: Can't resolve 'fs' in 'node_modules/@aws-sdk/lib-storage/dist/es
Describe the bug
Angular project not building because of FS error, is there no way to upload big files to s3 via Angular 11 with v3 sdk ?
Your environment
Angular - 11, Win 10
SDK version number
3.20.0
Is the issue in the browser/Node.js/ReactNative?
Browser
Details of the browser/Node.js/ReactNative version
Paste output of npx envinfo --browsers
or node -v
or react-native -v
v14.15.1
Steps to reproduce
const uploadParams = {
Bucket: this.bucketName,
Key: `podcasts/${this.userInfo.identityId}/${file.name}`,
Body: file
};
try {
const parallelUploads3 = new Upload({
client: this.s3,
params: uploadParams,
});
parallelUploads3.on("httpUploadProgress",progressFunc);
await parallelUploads3.done();
} catch (err) {
return console.error(err);
}
Observed behavior
Angular app crashes
Expected behavior
Use the library
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
duplicate of #2136
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 6
- Comments: 23 (10 by maintainers)
@ajredniwja Here’s a repo that reproduces the issue. I used Angular CLI to generate a new v11 project, then added
@aws-sdk/lib-storage
and@aws-sdk/client-s3
, then just pasted in the example from the lib-storage repo.@robec1982 It’s working for me now with the latest version of the sdk
For Angular using web-pack 5 it is using the node config to build which causes this error, which uses
fs
as seen here, but it needs to use the browser config as which doesn’t usefs
. I believe, it should be a web-pack issue since it is not able to load the correct config. Not sure how to achieve that in an Angular project but working on it, will discuss it with the team to find more on the issue.After applying those fixes, it still fails with Angular 12, that uses Webpack v5.
This is the core of the package.json used:
Also
tsconfig
is configured with:Any ideas?
@grothem thanks, I’ll try to work with it, would be some time.