truffle-box / react-box

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

Can't Find Contract - Symlink Doesn't Work on Windows! #68

Closed rori4 closed 5 years ago

rori4 commented 6 years ago

Hello, after the recent commits the react box is not working on windows.

After compiling and running 'npm run start' from the client folder I get the following error: (This was not mentioned in the official documentation but in the repository of the new contributor - https://github.com/adrianmcli/truffle-react )

After I ran the client i got this error:

Failed to compile ./src/App.js Module not found: Can't resolve './contracts/SimpleStorage.json' in 'F:\reactBox\client\src'

I understand that the issue is the creation of a symlink and so I tried running the 'npm run link-contracts:win32' with no luck.

It gave me an error.

I can confirm that this commit is working properly -> https://github.com/truffle-box/react-box/tree/9fb7ed6c0253c71b574bf160072bc7eb9fdd0336

How can I fix this? And if it can't be fixed is there a way to use truffle unbox to deploy the above commit directly?

rori4 commented 6 years ago

OK... after more than 2 hours of digging around here are the issues of the latest commit and how to fix them:

Hope this helps someone. I don't know what was so bad with the previous commit that we had to change the whole structure.

TamanShergill commented 5 years ago

Hi Rori4,

I am trying the same as npm run "link-contracts:win32": "cd src && mklink /D contracts ..\..\build\contracts" or npm run link-contracts:win32: cd src && mklink /D contracts ..\..\build\contracts

It still doesn't work. Do you mean to change the command in some script?

benjamistan commented 5 years ago

In cmd (Run as administrator), go to your /client/src file and simply run mklink /D contracts ..\..\build\contracts

Adrianf23 commented 5 years ago

@benjamistan this worked for me! Thanks

michaelseemichaeldo commented 5 years ago

@benjamistan when I enter your command it says "Cannot create a file when that file already exists."

adrianmcli commented 5 years ago

Symlink should no longer be required!

This is because we are now using the contracts_build_directory setting here:

contracts_build_directory: path.join(__dirname, "client/src/contracts")

This ensures that the build artifacts are sent to the contracts folder inside the src folder in the React app.