[英]High CPU usage from Node.js when running vue-cli-service serve
The CPU usage by Node goes well over 100% when I run my npm script, which is using vue-cli-service serve
.当我运行使用
vue-cli-service serve
npm 脚本时,Node 的 CPU 使用率超过 100%。 How can I debug this issue?我该如何调试这个问题?
I'm working on a Mac, Node installed through nvm.我在 Mac 上工作,Node 通过 nvm 安装。 Node version: 10.16, npm version: 6.9
节点版本:10.16,npm 版本:6.9
在 MacOSX 上安装fsevents
模块将有助于降低 CPU 使用率。
npm install fsevents -g
npm rebuild fsevents
The problem was caused by the polling option.问题是由轮询选项引起的。
Removing poll: true
from the watchOptions
in the webpack config - fixed the problem for me.从 webpack 配置中的
watchOptions
中删除poll: true
- 为我解决了这个问题。
i use linux in virtualbox for dev purpose, and i have shared folder from windows host to linux guest.我在 virtualbox 中使用 linux 用于开发目的,并且我有从 Windows 主机到 linux 来宾的共享文件夹。 and my my vue project is stored in my hdd and shared with vbox.
我的 vue 项目存储在我的硬盘中并与 vbox 共享。
so that i have to used {devServer: watchOptions: {poll: true}}
in my vue.config.js for hot reload to works.所以我必须在我的 vue.config.js 中使用
{devServer: watchOptions: {poll: true}}
来热重载工作。 this was causing the high cpu usage problem.这导致了高 CPU 使用率问题。
so i put my code in guest hdd and set poll:false and problem has gone.所以我将我的代码放在来宾硬盘中并设置 poll:false 并且问题消失了。
hope someone find this helpfull.希望有人觉得这有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.