Truffle webpack localhost can access, and the IP address is inaccessible solution _truffle

Source: Internet
Author: User

Recently learning Ethereum, with truffle webpack encountered a problem, is to start the service can use localhost:8080 access, but can not use ip:8080 access. In this way, other computers will not be able to access their applications.

This machine ip:219.216.65.127

To do a little experiment, nodejs+express, I started the application with node, both with localhost:3000 access, with 219.216.65.127:3000 access, and another computer to access. So I think about the configuration of the webpack is not a problem.

The solution to find someone on the Web is: npm run dev--host "0.0.0.0"

Unfortunately, I did not succeed (I do not know where the problem, trouble who knows to help me leave a message, thank you)
The results are as follows:

$ npm Run dev--host 219.216.65.127 > truffle-init-webpack@0.0.2 dev/home/hepu/desktop/test/test > Webpack-dev-ser Ver "219.216.65.127" Project is running in http://localhost:8080/webpack output is served from/hash:2e535af56b1ecc259        B4A version:webpack 2.7.0 time:2047ms Asset Size Chunks Chunk Names app.js 1.35 MB 0 [emitted] [big] main index.html 925 bytes [emitted] chunk {0} app.js (main) 1.32 MB [ent RY] [rendered] [+]./~/web3/index.js 193 bytes {0} [built] [n]./app/javascripts/app.js 3.64 KB {0} [built] [87 ] (webpack)-dev-server/client?http://localhost:8080 5.83 KB {0} [built] [+]./build/contracts/metacoin.json 2.62 KB {0
  [built] [127]./~/loglevel/lib/loglevel.js 6.74 KB {0} [built] [161]./~/strip-ansi/index.js 161 bytes {0} [built] [163]./~/style-loader/addstyles.js 6.91 KB {0} [built] [164]./app/stylesheets/app.css 905 bytes {0} [built] [171]. /~/truffle-contract/indeX.js 2.64 KB {0} [built] [206]./~/url/url.js 23.3 KB {0} [built] [241] (Webpack)-dev-server/client/overlay.js 3.6 kb {0} [built] [242] (webpack)-dev-server/client/socket.js 856 bytes {0} [built] [244] (webpack)/hot nonrecursive g$ 160 bytes {0} [built] [245] (webpack)/hot/emitter.js + bytes {0} [built] [247] multi (webpack)-dev-server/client?h ttp://localhost:8080./app/javascripts/app.js 219.216.65.127 bytes {0} [built] + 233 hidden modules ERROR in mult I (Webpack)-dev-server/client?http://localhost:8080./app/javascripts/app.js 219.216.65.127 Module not found:error: Can ' t resolve ' 219.216.65.127 ' in '/home/hepu/desktop/test/test ' @ multi (webpack)-dev-server/client?http://localhost : 8080./app/javascripts/app.js 219.216.65.127 webpack:failed to compile.

Method 1: According to the above error hint, I found the node_modules directory of the Webpack-dev-server/.bin/webpack-dev-server.js file, inside the yargs.options in the field

' Host ': {
        type: ' String ',
        //default: ' localhost ',
        default: ' 219.216.65.127 ',  //New
        describe: ' The HOSTNAME/IP address the server would bind to,
        Group:connection_group
    }

Change the default IP address to the IP, restart the application, and now be able to use 219.216.65.127:8080 access. But it can't be accessed with localhost:8080.

Method 2:https://github.com/webpack/webpack-dev-server/issues/147
In the above link found a solution, that is, directly with Node_modules/.bin/webpack-dev-server–hot–host 219.216.65.127 boot service, without npm run dev.
Start successful

~/desktop/test/test$ node_modules/.bin/webpack-dev-server--hot--host 219.216.65.127 Project is running at http:// 219.216.65.127:8080/webpack output is served from/hash:1120d8dcc38ac654dcf2 version:webpack 2.7.0 time:2038ms A Sset Size Chunks Chunk Names app.js 1.38 MB 0 [emitted] [big] main index.html 9 bytes [emitted] chunk {0} app.js (main) 1.32 MB [Entry] [rendered] [m]./~/web3/index.js 193 B ytes {0} [built] [i] (webpack)/hot/emitter.js bytes {0} [built] [$]./app/javascripts/app.js 3.64 KB {0} [built ] [M] (webpack)-dev-server/client?http://219.216.65.127:8080 5.83 kB {0} [built] [m] (webpack)/hot/dev-server.js 1 . KB {0} [built] [$]./build/contracts/metacoin.json 2.62 KB {0} [built] [129]./~/loglevel/lib/loglevel.js 6.74 K B {0} [built] [163]./~/strip-ansi/index.js 161 bytes {0} [built] [166]./app/stylesheets/app.css 905 bytes {0} [built ] [173]./~/truffle-contract/Index.js 2.64 KB {0} [built] [i]./~/url/url.js 23.3 KB {0} [built] [244] (Webpack)-dev-server/client/socket.js 856 bytes {0} [built] [246] (Webpack)/hot nonrecursive ^\.\/log$ 160 bytes {0} [built] [247] (Webpack)/hot/log-apply-resul T.js 1.02 KB {0} [built] [249] multi (webpack)-dev-server/client?http://219.216.65.127:8080 webpack/hot/dev-server./ap P/javascripts/app.js bytes {0} [built] + 235 hidden modules webpack:compiled.

As with Method 1, you can only use Ip+port access, you can not use the Localhost+port access.

This can be accessed with 219.216.65.127:8080 on another computer.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.