-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Babel webpack require #1105
Comments
I am not sure if the same issue, Using: The error disappears, if i do not require web3.
|
My temporary solution:
|
I'm using React, Babel and Webpack and I get 3 web3 (sub packages) related errors
I do have an .babelrc which is of the form {
"presets": ["env", "stage-0", "react"],
"env": {
"production": {
"plugins": [
"transform-react-remove-prop-types"
]
}
}
} not sure if that might be interfering somehow... If I comment out the web3 import everything works as expected. Any advice would be greatly appreciated. |
I managed to solve it. It was an error on my side. My path to exclude node_modules from my use of babel-loader in my webpack config was set incorrectly and hence, Webpack was attempting to transpile everything in node_modules. So if still relevant @adibas03, your issue might be solved by explicitly telling Webpack to exclude node_modules for babel-loader: {
test: /\.jsx?$/,
use: 'babel-loader',
exclude: path.resolve(__dirname, 'node_modules')
} |
thanks @michaeldzjap |
@adolfo-flores I think I figured this out! Here's the webpack config that seems to be working for me:
|
You are likely only including ".js" files or ".jsx" files. This library is looking for a .node library so you probably have to add it to your extensions. And you'll have to add the node-loader
|
This is a known issue: web3/web3.js#1105
Same issue still exists today. |
I'm getting the following error just trying to require web3 version 1.0.0-beta.23:
const Web3 = require('web3');
This issue seems related to issue #923, the weird thing is that i can require it and compile it without problem on another project that does not use webpack.
Im using Webpack and babel-loader on a Node application.
My package.json:
my webpack config:
Does anyone know why i'm not able to require it with webpack but vanilla node has no problem?
Here is the error message:
The text was updated successfully, but these errors were encountered: