Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

控制台显示的IP地址有点问题 #3266

Closed
liaowentuan opened this issue Jan 9, 2019 · 11 comments · Fixed by #4083
Closed

控制台显示的IP地址有点问题 #3266

liaowentuan opened this issue Jan 9, 2019 · 11 comments · Fixed by #4083

Comments

@liaowentuan
Copy link

Version

3.2.0

Environment info

 System:
    OS: Windows 10
    CPU: (4) x64 Intel(R) Core(TM) i3-4160 CPU @ 3.60GHz
  Binaries:
    Node: Not Found
    Yarn: Not Found
    npm: 6.2.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: 41.16299.785.0
  npmPackages:
    @vue/babel-preset-app:  3.2.0
    @vue/cli-overlay:  3.2.0
    @vue/cli-plugin-babel: ^3.2.0 => 3.2.0
    @vue/cli-plugin-typescript: ^3.2.0 => 3.2.0
    @vue/cli-service: ^3.2.0 => 3.2.0
    @vue/cli-shared-utils:  3.2.0
    @vue/component-compiler-utils:  2.3.1
    @vue/preload-webpack-plugin:  1.1.0
    @vue/web-component-wrapper:  1.2.0
    babel-helper-vue-jsx-merge-props:  2.0.3
    babel-plugin-transform-vue-jsx:  4.0.1
    vue: ^2.5.17 => 2.5.21
    vue-class-component: ^6.0.0 => 6.3.2
    vue-hot-reload-api:  2.3.1
    vue-lazyload:  1.2.3
    vue-loader:  15.4.2
    vue-property-decorator: ^7.0.0 => 7.2.0
    vue-router: ^3.0.1 => 3.0.2
    vue-style-loader:  4.1.2
    vue-template-compiler: ^2.5.17 => 2.5.21
    vue-template-es2015-compiler:  1.6.0
    vuex: ^3.0.1 => 3.0.1
  npmGlobalPackages:
    @vue/cli: Not Found

Steps to reproduce

vue.config.js
devServer: {
// host: 'localhost',
host: "0.0.0.0",
port: 8000,
npm run serve 后,别的小伙伴使用 Network地址 无法打开

What is expected?

npm run serve 后上面的Network地址显示的是别人都能访问的地址

What is actually happening?

我的电脑有3个IPv4的地址,使用的是最下面的那个无线局域网适配器的IP地址;而控制台显示的是最上面那个地址,故无法使用别的电脑通过命令行上显示的 ‘Network‘地址打开


npm run serve 后上面的Network地址要么不显示;要么就全显示吧

@liaowentuan
Copy link
Author

image

@shenliangv
Copy link

shenliangv commented May 16, 2019

I had the same problem (#2534).
It seems that when there are multiple network adapters, the program did not get the correct ip address.
When I disable all network adapters until the one I'm using is left, the expected results were achieved.

@shenliangv
Copy link

This problem seems to be solved by modifying the file packages/@vue/cli-service/lib/util/prepareURLs.js.
Need to install default-gateway dependencies first

line ~ 12

const defaultGateway = require('default-gateway')

line ~ 36

// lanUrlForConfig = address.ip()
const result = defaultGateway.v4.sync()
lanUrlForConfig = address.ip(result && result.interface)

@sodatea

@WONDERlust91
Copy link

This problem seems to be solved by modifying the file packages/@vue/cli-service/lib/util/prepareURLs.js.
Need to install default-gateway dependencies first

line ~ 12

const defaultGateway = require('default-gateway')

line ~ 36

// lanUrlForConfig = address.ip()
const result = defaultGateway.v4.sync()
lanUrlForConfig = address.ip(result && result.interface)

@sodatea

My vue-cli version is 3.8.3

There is also something wrong when the Interface name is in Chinese words.

image

image

I changed the Interface name to English. The problem solved.

image

image

@sodatea

@haoqunjiang
Copy link
Member

@WONDERlust91 Thanks for the hint. I don't have a Windows computer at the moment so I can't debug it until later. Could you raise an issue to https://github.com/silverwind/default-gateway? Seems they failed to parse Unicode interface names.

@WONDERlust91
Copy link

WONDERlust91 commented Jun 14, 2019

@WONDERlust91 Thanks for the hint. I don't have a Windows computer at the moment so I can't debug it until later. Could you raise an issue to https://github.com/silverwind/default-gateway? Seems they failed to parse Unicode interface names.

I've already raised an issue to default-gateway.

@athrunsun
Copy link

Be aware that the IP of your router also matters - it has to match ^10[.]|^172[.](1[6-9]|2[0-9]|3[0-1])[.]|^192[.]168[.] to be a "private IP".

I changed the IP of my router from 192.168.1.1 to 172.168.1.1 recently and Network: unavailable suddenly shows up. 172.16.1.1 will do the trick.

@zhoufanglu
Copy link

Version

3.2.0

Environment info

 System:
    OS: Windows 10
    CPU: (4) x64 Intel(R) Core(TM) i3-4160 CPU @ 3.60GHz
  Binaries:
    Node: Not Found
    Yarn: Not Found
    npm: 6.2.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: 41.16299.785.0
  npmPackages:
    @vue/babel-preset-app:  3.2.0
    @vue/cli-overlay:  3.2.0
    @vue/cli-plugin-babel: ^3.2.0 => 3.2.0
    @vue/cli-plugin-typescript: ^3.2.0 => 3.2.0
    @vue/cli-service: ^3.2.0 => 3.2.0
    @vue/cli-shared-utils:  3.2.0
    @vue/component-compiler-utils:  2.3.1
    @vue/preload-webpack-plugin:  1.1.0
    @vue/web-component-wrapper:  1.2.0
    babel-helper-vue-jsx-merge-props:  2.0.3
    babel-plugin-transform-vue-jsx:  4.0.1
    vue: ^2.5.17 => 2.5.21
    vue-class-component: ^6.0.0 => 6.3.2
    vue-hot-reload-api:  2.3.1
    vue-lazyload:  1.2.3
    vue-loader:  15.4.2
    vue-property-decorator: ^7.0.0 => 7.2.0
    vue-router: ^3.0.1 => 3.0.2
    vue-style-loader:  4.1.2
    vue-template-compiler: ^2.5.17 => 2.5.21
    vue-template-es2015-compiler:  1.6.0
    vuex: ^3.0.1 => 3.0.1
  npmGlobalPackages:
    @vue/cli: Not Found

Steps to reproduce

vue.config.js
devServer: {
// host: 'localhost',
host: "0.0.0.0",
port: 8000,
npm run serve 后,别的小伙伴使用 Network地址 无法打开

What is expected?

npm run serve 后上面的Network地址显示的是别人都能访问的地址

What is actually happening?

我的电脑有3个IPv4的地址,使用的是最下面的那个无线局域网适配器的IP地址;而控制台显示的是最上面那个地址,故无法使用别的电脑通过命令行上显示的 ‘Network‘地址打开

npm run serve 后上面的Network地址要么不显示;要么就全显示吧

请问 你这个问题解决了吗?

@liaowentuan
Copy link
Author

liaowentuan commented Dec 4, 2020 via email

@zhoufanglu
Copy link

------------------ 原始邮件 ------------------ 发件人: "vuejs/vue-cli" <notifications@github.com>; 发送时间: 2020年12月4日(星期五) 上午10:47 收件人: "vuejs/vue-cli"<vue-cli@noreply.github.com>; 抄送: "獬豸一族"<996002654@qq.com>;"Author"<author@noreply.github.com>; 主题: Re: [vuejs/vue-cli] 控制台显示的IP地址有点问题 (#3266) Version 3.2.0 Environment info System: OS: Windows 10 CPU: (4) x64 Intel(R) Core(TM) i3-4160 CPU @ 3.60GHz Binaries: Node: Not Found Yarn: Not Found npm: 6.2.0 - C:\Program Files\nodejs\npm.CMD Browsers: Edge: 41.16299.785.0 npmPackages: @vue/babel-preset-app: 3.2.0 @vue/cli-overlay: 3.2.0 @vue/cli-plugin-babel: ^3.2.0 => 3.2.0 @vue/cli-plugin-typescript: ^3.2.0 => 3.2.0 @vue/cli-service: ^3.2.0 => 3.2.0 @vue/cli-shared-utils: 3.2.0 @vue/component-compiler-utils: 2.3.1 @vue/preload-webpack-plugin: 1.1.0 @vue/web-component-wrapper: 1.2.0 babel-helper-vue-jsx-merge-props: 2.0.3 babel-plugin-transform-vue-jsx: 4.0.1 vue: ^2.5.17 => 2.5.21 vue-class-component: ^6.0.0 => 6.3.2 vue-hot-reload-api: 2.3.1 vue-lazyload: 1.2.3 vue-loader: 15.4.2 vue-property-decorator: ^7.0.0 => 7.2.0 vue-router: ^3.0.1 => 3.0.2 vue-style-loader: 4.1.2 vue-template-compiler: ^2.5.17 => 2.5.21 vue-template-es2015-compiler: 1.6.0 vuex: ^3.0.1 => 3.0.1 npmGlobalPackages: @vue/cli: Not Found Steps to reproduce vue.config.js devServer: { // host: 'localhost', host: "0.0.0.0", port: 8000, npm run serve 后,别的小伙伴使用 Network地址 无法打开 What is expected? npm run serve 后上面的Network地址显示的是别人都能访问的地址 What is actually happening? 我的电脑有3个IPv4的地址,使用的是最下面的那个无线局域网适配器的IP地址;而控制台显示的是最上面那个地址,故无法使用别的电脑通过命令行上显示的 ‘Network‘地址打开 npm run serve 后上面的Network地址要么不显示;要么就全显示吧 请问 你这个问题解决了吗? — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

---------- 不好意思,由于离开了上家公司了。所以没有当时的复杂环境。我也没法验证这个问题

好吧,我这是个人电脑出这个问题了。。不知道是不是环境变量的问题

@zoudingyi
Copy link

好吧,我这是个人电脑出这个问题了。。不知道是不是环境变量的问题

请问你解决了吗?我也怀疑是环境变量问题。

ZanderOlidan pushed a commit to ZanderOlidan/vue-cli-service-chalkfix that referenced this issue Feb 5, 2024
ZanderOlidan pushed a commit to ZanderOlidan/vue-cli-service-chalkfix that referenced this issue Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants