truffle-box / react-box

Truffle, Webpack and React boilerplate.
https://truffle-box.github.io/
MIT License
736 stars 251 forks source link

Module not found: Can't resolve './build/contracts/SimpleStorage.json' #102

Closed eunnovax closed 5 years ago

eunnovax commented 5 years ago

Whenever I execute step 5: cd client npm run start

I get the above error. It kind of make sense because /build folder is not inside /src folder, but since import SimpleStorageContract from "./build/contracts/SimpleStorage.json"; command has been in App.js by default, it doesn't make any sense to me.

eunnovax commented 5 years ago

Solved the issue by: 1) first installing symlink package: npm i symlink-dir

2) then writing LinkContracts.js script in /client:

"use strict"; const symlinkDir = require("symlink-dir"); const path = require("path");

symlinkDir("../build/contracts", "src/contracts") .then(result => { console.log(result); //> { reused: false }

return symlinkDir("../build/contracts", "src/contracts");

}) .then(result => { console.log(result); //> { reused: true } }) .catch(err => console.error(err));

3) and at last creating symlink command in package.json scripts: "scripts": { "link-contracts": "node LinkContracts.js" }