Cannot build project with webpack v4
See original GitHub issueBug report
Cannot build a webpack project with the latest SDK installed, @aws-sdk/lib-storage@3.17.0
. I get the following error: Module not found: Error: Can't resolve 'fs' in ...
Setup
Below is the minimal setup for reproducing this problem.
$ tree
.
├── package-lock.json
├── package.json
└── src
└── index.js
1 directory, 3 files
Contents of package.json
:
{
"name": "ttt",
"version": "1.0.0",
"private": true,
"scripts": {
"build": "webpack --mode development"
},
"devDependencies": {
"webpack": "^4.46.0",
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^3.11.2"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.17.0",
"@aws-sdk/lib-storage": "^3.17.0"
}
}
Contents of src/index.js
:
import { S3Client } from '@aws-sdk/client-s3';
import { Upload } from '@aws-sdk/lib-storage';
console.log('+=+ S3Client', S3Client);
console.log('+=+ Upload', Upload);
What is the current behavior?
I get the following error:
ERROR in ./node_modules/@aws-sdk/lib-storage/dist/es/runtimeConfig.js
Module not found: Error: Can't resolve 'fs' in '/Users/korya/dev/ttt/node_modules/@aws-sdk/lib-storage/dist/es'
@ ./node_modules/@aws-sdk/lib-storage/dist/es/runtimeConfig.js 3:0-31 7:106-115
@ ./node_modules/@aws-sdk/lib-storage/dist/es/bytelength.js
@ ./node_modules/@aws-sdk/lib-storage/dist/es/Upload.js
@ ./node_modules/@aws-sdk/lib-storage/dist/es/index.js
@ ./src/index.js
If the current behavior is a bug, please provide the steps to reproduce.
- Create the project
- Install deps:
npm install
- Try to build it using
npm run build
(or just by runningnpx webpack
)
What is the expected behavior?
The project should be successfully built and Upload
imported @aws-sdk/lib-storage
should be configured to work in browser’s environment (as expected).
Other relevant information: webpack version: 4.46.0 Node.js version: 15.14.0 npm version: 7.12.1 Operating System: MacOS Catalina Additional tools:
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (7 by maintainers)
Top Results From Across the Web
Not able to build project using webpack and babel
SyntaxError: Cannot use import statement outside a module at Module._compile (internal/modules/cjs/loader.js:891:18) at Object.
Read more >To v5 from v4 - webpack
This guide aims to help you migrating to webpack 5 when using webpack directly. If you are using a higher level tool to...
Read more >Configuration - webpack
Out of the box, webpack won't require you to use a configuration file. However, it will assume the entry point of your project...
Read more >Development - webpack
webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable...
Read more >Output Management - webpack
html file manually. However, a few plugins exist that will make this process much easier to manage. Preparation. First, let's adjust our project...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks again!
Just an update. The following config worked for
webpack@4.46.0
:Great!