Skip to content

初始化vue-cli3.0项目,修改项目.vue文件内容浏览器没有自动刷新 #2195

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

Closed
libin1991 opened this issue Aug 14, 2018 · 25 comments
Labels
needs reproduction This issue is missing a minimal runnable reproduction, provided by the author

Comments

@libin1991
Copy link

Version

3.0.0

Node and OS info

8.11.1 / npm / mac

Steps to reproduce

初始化vue-cli3.0项目,修改项目.vue文件内容浏览器没有自动刷新

What is expected?

修改项目.vue文件内容浏览器自动刷新

What is actually happening?

需要手动刷新

@haoqunjiang
Copy link
Member

能否提供一下代码以供我们排查?光看描述我们很难帮上忙

@haoqunjiang haoqunjiang added the needs reproduction This issue is missing a minimal runnable reproduction, provided by the author label Aug 14, 2018
@season19840122
Copy link

我也是一样,不管是使用 vue ui 运行 npm run serve 还是直接运行 npm run serve 热更新一直是 wait 状态,我的 vue-cli 版本是 3.0.0

@libin1991
Copy link
Author

@sodatea 你可以用vue cli3初始化一个Vue项目跑起来看看 ,修改vue文件的内容,看看浏览器会自动刷新吗?

@season19840122
Copy link

@libin1991 好的我试试,我再其他的 issues 中看到他们说要把 NODE_ENV=development 但我不知道在哪里设置

@haoqunjiang
Copy link
Member

@libin1991 会啊……所以才需要更多信息。

初始化选项是哪些?是否改过 vue.config.js?网页是否有报错?WebSocket 连接是否成功?浏览器是 Chrome 还是 Safari?是所有浏览器都有问题还是只有这一个?这些信息都能够帮助排查问题的

@haoqunjiang
Copy link
Member

@season19840122 npm run serve 时默认就是 development

@season19840122
Copy link

@sodatea 哦,我修改过 vue.config.js

@libin1991
Copy link
Author

libin1991 commented Aug 14, 2018

@sodatea 麻烦看看多页面配置 https://github.com/wanghanzhen/vue-multi-page 这个项目,或者这个单页 https://github.com/wywppkd/vue-template ,我试了修改.vue文件,浏览器都没有自动刷新,需要手动刷新才可以

@AmosXu
Copy link

AmosXu commented Aug 14, 2018

我把vue-cli3相关代码拷贝到我的项目中也无法热加载,后来我把自己项目中的代码拷到vue-cli3生成的项目中,就可以热加载了,不知道你和我情况是否相同 @libin1991

@haoqunjiang
Copy link
Member

@libin1991 都没办法复现……控制台是否有报错?

@libin1991
Copy link
Author

@sodatea ,你的可以正常热加载?

@libin1991
Copy link
Author

@AmosXu 我是从网上找了几个vue-cli的项目随便跑跑都不可以,

@haoqunjiang
Copy link
Member

@libin1991 是啊……所以需要你提供更多信息
刚进入页面时发出的 WebSocket 连接是否成功?网页控制台是否有报错?

@season19840122
Copy link

@libin1991 经我测试,重新创建一个 vue 项目是 HMR 是可以正常使用的,但是我把我现在的 vue.config.js 放进去后 HMR 就不正常了,但是我注释掉其中部分跟 webpack 有关的,还有 pages 选项部分就正常了。@sodatea

@season19840122
Copy link

@sodatea 麻烦也帮我看下我的项目 https://github.com/season19840122/Vue-Cli-Demo

@season19840122
Copy link

@sodatea 控制台没报错,一切正常

@yyx990803
Copy link
Member

yyx990803 commented Aug 14, 2018

@libin1991 现在的情况是热加载只有在你的机器上不工作,所以你不提供额外的信息我们做不了任何事情。

@season19840122 请不要在别人的 issue 下面让人看自己的问题,这样会让讨论很混乱。你们遇到的未必是同样的问题。正确的做法是开一个新的 issue 带上自己的重现。

@twoer
Copy link

twoer commented Aug 27, 2018

我也遇到了,使用 cnpm 安装的 node 模块 就是无法 HMR,换成 npm 安装 就正常,大家可以试试。

@season19840122
Copy link

@twoer 这么奇怪?

@haoqunjiang
Copy link
Member

cnpm 确实会导致热更新失效
#1559

@season19840122
Copy link

@sodatea 厉害,我换成 npm 就好了,谢谢!

haoqunjiang added a commit to haoqunjiang/vue-cli that referenced this issue Aug 31, 2018
Currently in Vue CLI we set the default `symlinks` config to `false`.
This setting is counterintuitive, and inconsitent with webpack's default
configuration, per https://webpack.js.org/configuration/resolve/#resolve-symlinks

The change of default `symlinks` value is introduced by vuejs@5b4df14
It is most likely a duplicate of vuejs@145492b

Since several third-party npm clients uses symlinks to speed up installation
(e.g. cnpm, pnpm...), that change breaks webpack HMR for their users.
See vuejs#1559, vuejs#2195, vuejs#2284

This commit also fixes vuejs#1609
haoqunjiang added a commit to haoqunjiang/vue-cli that referenced this issue Aug 31, 2018
Currently in Vue CLI we set the default `symlinks` config to `false`.
This setting is counterintuitive, and inconsitent with webpack's default
configuration, per https://webpack.js.org/configuration/resolve/#resolve-symlinks

The change of default `symlinks` value is introduced by vuejs@5b4df14
It is most likely a duplicate of vuejs@145492b

Since several third-party npm clients uses symlinks to speed up installation
(e.g. cnpm, pnpm...), that change breaks webpack HMR for their users.
See vuejs#1559, vuejs#2195, vuejs#2284

This commit also fixes vuejs#1609
haoqunjiang added a commit to haoqunjiang/vue-cli that referenced this issue Sep 3, 2018
Currently in Vue CLI we set the default `symlinks` config to `false`.
This setting is counterintuitive, and inconsitent with webpack's default
configuration, per https://webpack.js.org/configuration/resolve/#resolve-symlinks

The change of default `symlinks` value is introduced by vuejs@5b4df14
It is most likely a duplicate of vuejs@145492b

Since several third-party npm clients uses symlinks to speed up installation
(e.g. cnpm, pnpm...), that change breaks webpack HMR for their users.
See vuejs#1559, vuejs#2195, vuejs#2284

This commit also fixes vuejs#1609
haoqunjiang added a commit to haoqunjiang/vue-cli that referenced this issue Sep 4, 2018
Currently in Vue CLI we set the default `symlinks` config to `false`.
This setting is counterintuitive, and inconsitent with webpack's default
configuration, per https://webpack.js.org/configuration/resolve/#resolve-symlinks

The change of default `symlinks` value is introduced by vuejs@5b4df14
It is most likely a duplicate of vuejs@145492b

Since several third-party npm clients uses symlinks to speed up installation
(e.g. cnpm, pnpm...), that change breaks webpack HMR for their users.
See vuejs#1559, vuejs#2195, vuejs#2284

This commit also fixes vuejs#1609
haoqunjiang added a commit that referenced this issue Sep 5, 2018
Currently in Vue CLI we set the default `symlinks` config to `false`.
This setting is counterintuitive, and inconsistent with webpack's default
configuration, per https://webpack.js.org/configuration/resolve/#resolve-symlinks

The change of default `symlinks` value is introduced by 5b4df14
It is most likely a duplicate of 145492b

Since several third-party npm clients uses symlinks to speed up installation
(e.g. cnpm, pnpm...), that change breaks webpack HMR for their users.
See #1559, #2195, #2284

This commit also fixes #1609
@qiaoqiao10001
Copy link

但是我是用的yarn 怎么还是失效了呢

@WeTis
Copy link

WeTis commented Dec 24, 2018

@qiaoqiao10001 使用yarn serve时 先执行一步 yarn 然后yarn serve 就可以了

@qiaoqiao10001
Copy link

@qiaoqiao10001 使用yarn serve时 先执行一步 yarn 然后yarn serve 就可以了

试过。浏览器还是没反应,谷歌浏览器是系统默认

@sepld
Copy link

sepld commented Jan 3, 2019

@vue/cli-service包中有webpack 和 webpack-dev-server这两个依赖. 而且webpack-dev-server这个包又依赖webpack, 此时. 这两个依赖的webpack包版本要相同. 随便改哪个都行,只要一样就可以.
改完在修改的包里 npm up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs reproduction This issue is missing a minimal runnable reproduction, provided by the author
Projects
None yet
Development

No branches or pull requests

9 participants