truffle-init-webpack 项目

  1. Usage
    To initialize a project with this exapmple, run truffle init webpack inside an empty directory.

  2. Building and the frontend
    First run truffle compile, then run truffle migrate to deploy the contracts onto your network of choice (default “development”).

    Then run npm run dev to build the app and serve it on http://localhost:8080

直接安装这会出现错误:

nk@ubuntu:~/myProject$ truffle migrate
Error: Invalid JSON RPC response: ""
    at Object.InvalidResponse (/usr/local/node/lib/node_modules/truffle/node_modules/web3/lib/web3/errors.js:35:16)
    at XMLHttpRequest.request.onreadystatechange (/usr/local/node/lib/node_modules/truffle/node_modules/web3/lib/web3/httpprovider.js:115:32)
    at XMLHttpRequestEventTarget.dispatchEvent (/usr/local/node/lib/node_modules/truffle/node_modules/xhr2/lib/xhr2.js:64:18)
    at XMLHttpRequest._setReadyState (/usr/local/node/lib/node_modules/truffle/node_modules/xhr2/lib/xhr2.js:354:12)
    at XMLHttpRequest._onHttpRequestError (/usr/local/node/lib/node_modules/truffle/node_modules/xhr2/lib/xhr2.js:544:12)
    at ClientRequest. (/usr/local/node/lib/node_modules/truffle/node_modules/xhr2/lib/xhr2.js:414:24)
    at emitOne (events.js:96:13)
    at ClientRequest.emit (events.js:188:7)
    at Socket.socketErrorListener (_http_client.js:309:9)
    at emitOne (events.js:96:13)

解决方法:

I figure it out. The reason is because no Ethereum client is running. we just need to run testrpc in another terminal.

另起一终端:
nk@ubuntu:~$ testrpc -a

问题解决.

https://github.com/trufflesuite/truffle-init-webpack
https://github.com/trufflesuite/truffle/issues/393

你可能感兴趣的:(区块链技术)