Adam
Adam

Reputation: 677

How to deploy React (with solidity smart contracts) to S3 without error

So we wrote a Dapp with React in frontend and Solidity to write smart contracts. The smart contracts are deployed in infura polygon testnet. Now we wanted to deploy the S3 to Amazon S3, but when we try we get an error. The error is:

Creating an optimized production build... 254Failed to compile. 255256./src/components/MarketPlace/MarketPlace.js 257Cannot find file '../artifacts/MillMarket' in './src/components/MarketPlace'. 258259260npm ERR! code ELIFECYCLE 261npm ERR! errno 1 262npm ERR! [email protected] build: npm run build:css && react-scripts build 263npm ERR! Exit status 1 264npm ERR! 265npm ERR! Failed at the [email protected] build script. 266npm ERR! This is probably not a problem with npm. There is likely additional logging output above. 267268npm ERR! A complete log of this run can be found in: 269npm ERR! /root/.npm/_logs/2021-10-01T12_32_04_354Z-debug.log 270271[Container] 2021/10/01 12:32:04 Command did not exit successfully npm run build exit status 1 272[Container] 2021/10/01 12:32:04 Phase complete: BUILD State: FAILED 273[Container] 2021/10/01 12:32:04 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: npm run build. Reason: exit status 1274[Container] 2021/10/01 12:32:04 Entering phase POST_BUILD275[Container] 2021/10/01 12:32:04 Phase complete: POST_BUILD State: SUCCEEDED 276[Container] 2021/10/01 12:32:04 Phase context status code: Message: 277[Container] 2021/10/01 12:32:04 Expanding base directory path: build 278[Container] 2021/10/01 12:32:04 Assembling file list 279[Container] 2021/10/01 12:32:04 Expanding build 280[Container] 2021/10/01 12:32:04 Expanding file paths for base directory build 281[Container] 2021/10/01 12:32:04 Assembling file list 282[Container] 2021/10/01 12:32:04 Expanding */ 283[Container] 2021/10/01 12:32:04 Found 8 file(s) 284[Container] 2021/10/01 12:32:04 Phase complete: UPLOAD_ARTIFACTS State: SUCCEEDED 285[Container] 2021/10/01 12:32:04 Phase context status code: Message: 286

Any idea what I can do to fix this? I think the "Cannot find file '../artifacts/MillMarket' in './src/components/MarketPlace'" part of the error is what is breaking deployment. I have a feeling that Create React App is missing the artifacts folder for some reason in the build file, but I am not sure. Stuck for 2 days.

Thanks!

Upvotes: 0

Views: 286

Answers (2)

c_e_nwadike
c_e_nwadike

Reputation: 11

It is likely the contract "artifacts" directory is in gitignore.
If that is the case you could either remove "artifacts" from gitignore (which could mess with your repo) or place all relevant artifacts in a directory and import them into your frontend pages from the said directory.

Upvotes: 0

h.mavrodiev
h.mavrodiev

Reputation: 126

you need to recompile the smartcontract with Hardhat or Remix Ide and provide the missing ".JSON" files(artifacts) to the ReactJS app

 npx hardhat compile

https://hardhat.org/guides/compile-contracts.html

Upvotes: 0

Related Questions