Vue-cli: Open a new project and the page shows "[HMR] Hot Module Replacement is disabled"

Created on 20 Jun 2018  路  7Comments  路  Source: vuejs/vue-cli

Version

3.0.0-rc.3

Reproduction link

https://github.com/vuejs/vue-cli

Steps to reproduce

npm install [email protected]
vue create vue-test
choose default
cd vue-test
npm run serve

What is expected?

Open the new page show the app content

What is actually happening?

The page is not automatically opened. Open localhost:8080锛宼he page shows blank, and the console shows "Uncaught Error: [HMR] Hot Module Replacement is disabled."


I have tried many verisons of vue-cli, such as rc.2, beta.16, beta.10, this problem always appears. But in my friend's pc, he use the same version of vue-cli as me, do the same operations to create a new project, it works well.

Most helpful comment

But my friends's pc has also defined NODE_ENV in .zshrc, and his new project can normally work....I don't know why.

maybe he had it set to a different value, i.e. NODE_ENV=development

...which would be the exact value vue-cli is expecting.

I think it's never a good idea to have a predefined value for NODE_ENV in your environment.

Many projects rely on specific values for NODE_ENV to decide how to behave, and having this injected in the background will make it hard to track a bug, since it's only happening on your machine ...

All 7 comments

check: https://github.com/vuejs/vue-cli/issues/1617 and the last comments form @LinusBorg.

i had another issue but that defined NODE_ENV in .zshrc also caused this problem on my machine.

@podlebar
Yes, I also have NODE_ENV='dev' in my .zshrc file. After I delete it and create another project, it works well now. But my friends's pc has also defined NODE_ENV in .zshrc, and his new project can normally work....I don't know why.

Maybe he is using still a older version of vue-cli.
the change that breaks it for you came in beta-16.

But my friends's pc has also defined NODE_ENV in .zshrc, and his new project can normally work....I don't know why.

maybe he had it set to a different value, i.e. NODE_ENV=development

...which would be the exact value vue-cli is expecting.

I think it's never a good idea to have a predefined value for NODE_ENV in your environment.

Many projects rely on specific values for NODE_ENV to decide how to behave, and having this injected in the background will make it hard to track a bug, since it's only happening on your machine ...

@podlebar @LinusBorg thx!

with windows 10 and vue 3.0.0-rc.1 i was hitting the same bug last night
"Uncaught Error: [HMR] Hot Module Replacement is disabled."
i looked at my windows env but no NODE_ENV, for an eventual .zshrc, none ...
i was puzzled as what is reported here is related to NODE_ENV ...
my .env file was also not used ...

after putting a console.log in @vue\cli-service\lib\util\loadEnv.js i found that the process.env contained a NODE_ENV value equal to "undefined" therefore the condition failed because "undefined" is a string and not a type, so process.env was not overwritten with the config env.

using cross-env to specify the NODE_ENV in package.json solved my problem
"serve": "cross-env NODE_ENV=development vue-cli-service serve",

@c0urg3tt3 You are not on the latest rc 馃槈

Was this page helpful?
0 / 5 - 0 ratings