truffle-box / react-box

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

package.json file missing when running npm run start #91

Closed alexiskattan closed 5 years ago

alexiskattan commented 5 years ago

When I run npm run start with a fresh install I get an error saying

npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open 'XXXXX\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
adrianmcli commented 5 years ago

@alexiskattan Did you first cd into the client folder?

cd client
npm start
ghost commented 5 years ago

I think the argument being made here is that there should be a package.json integrating server and client for ease of use. This notion could be solved by setting up a Dockerfile with @adrianmcli 's commands above.

adrianmcli commented 5 years ago

@impetus1 I'm not sure that that's what @alexiskattan is asking for, I think he's just asking how to get it to work. The fact of the matter is, there is no server, at least not in the traditional sense since the "server" is now the blockchain.

There's a Truffle project that interacts with the blockchain and then there's a React project that makes use of the Truffle build artifacts to interact with the blockchain. Ideally, both projects should be in completely separate folders of a monorepo.

However, I would agree with you if the goal was to make a simple toy contract and a one-off frontend for it. I can see why some people would want that for small projects. But Truffle is designed for larger dapps. And in a larger dapp, I think it would be very detrimental to over-couple the Truffle and React projects together.

JessTaDa commented 5 years ago

@alexiskattan thanks for your response. Running "npm run start" in the client directory leads to another error : ./src/App.js Module not found: You attempted to import ../contracts/SimpleStorage.json which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.

It was originally routed to import SimpleStorageContract from "./contracts/SimpleStorage.json"; , which comes with the unbox-react code and I think it is incorrect. I've changed it to import SimpleStorageContract from "../contracts/SimpleStorage.json"; to be able to access the file. With no luck still. Any suggestions? Thanks! :)

adrianmcli commented 5 years ago

@JessTaDa This line is correct:

import SimpleStorageContract from "./contracts/SimpleStorage.json";

It imports from where the build artifacts would be generated (i.e. client/src/contracts), since we specified it in the truffle config:

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

If you're not able to find the JSON artifact, it's likely because you haven't compiled and migrated yet as per the README instructions. The JSON artifact files are only generated once you have a local testnet and when you have already migrated/deployed (i.e. use the truffle develop console and run the migrate command).

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 5 years ago

This issue has been closed, but can be re-opened if further comments indicate that the problem persists. Feel free to tag maintainers if there is no reply to further comments.

amanrathore commented 4 years ago

Getting the below error while using Docker run command:

/c/users/amandeep/desktop/frontend (master) $ docker run -it -p 3000:3000 -v /app/node_modules -v /.:/app fcd702193970 npm ERR! code ENOENT npm ERR! syscall open npm ERR! path /app/package.json npm ERR! errno -2 npm ERR! enoent ENOENT: no such file or directory, open '/app/package.json' npm ERR! enoent This is related to npm not being able to find a file. npm ERR! enoent

npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2020-04-06T08_28_36_308Z-debug.log

amanrathore commented 4 years ago

Without using -v commands, the container starts without any issue.

$ docker run -it -p 3000:3000 fcd702193970 //success