aionnetwork / aion_web3

Aion flavoured Web3 Javascript API
GNU General Public License v3.0
35 stars 30 forks source link

Error while deploying Aion dApp through frontend : fs.readFileSync is not a function #78

Closed parinaA closed 5 years ago

parinaA commented 5 years ago

Web3 version: 1.0.3 Description: I was deploying my contract through the frontend by using a MERN stack app and was unable to deploy it due to an error with fs which is a part of aion-web3. The initial error I got was:

Module not found: Error: Can't resolve 'fs' in '/home/parina/Documents/aion-counter/node_modules/aion-web3-eth/src'

To rectify this, I added

node: { fs: "empty" },

to my webpack.config.js file.

After this, I was successfully able to compile my project and start the server but on opening the project in the browser, the contract was not deployed and I got the following error in the console:

TypeError: fs.readFileSync is not a function at Contract.deploy (index.js?60f4:244) at _callee$ (Main.js?1523:40) at tryCatch (runtime.js?280d:65) at Generator.invoke [as _invoke] (runtime.js?280d:303) at Generator.prototype.<computed> [as next] (runtime.js?280d:117) at step (Main.js?1523:9) at eval (Main.js?1523:9) at new Promise (<anonymous>) at eval (Main.js?1523:9) at deploy (Main.js?1523:19)

Command(s) triggering the issue: N/A

API output: N/A

K-White commented 5 years ago

the fs library does not work on client-size, since you are using MERN try the deploy server-side