node.js - nodejs 抛出 TypeError: process.uptime is not a function
问题描述
我是 nodejs 的新手,我正在使用 prom-client,在使用process.uptime()
. 我尝试添加几个包但没有运气(前三个包是针对类似的其他错误):
"cluster": "^0.7.7",
"dns": "^0.2.2",
"repl": "^0.1.3",
"node": "^12.2.0",
"process": "^0.11.10"
这是我的其他包:
"@material-ui/core": "1.2.0",
"@material-ui/icons": "1.1.0",
"classnames": "^2.2.6",
"cross-env": "^5.2.0",
"jquery": "^3.4.1",
"js-yaml": "^3.13.1",
"npm": "^6.9.0",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-loader-spinner": "^2.3.0",
"react-number-format": "v3.0.0",
"react-scripts": "1.1.4",
"express": "4.15.3",
"prom-client": "^11.3.0"
我是否缺少一些可以提供所有这些功能的基本库?我可以在https://nodejs.org/api/process.html#process_process_uptime看到这个方法
我在浏览器上收到错误消息,但不在日志中:
TypeError: process.uptime is not a function
(anonymous function)
node_modules/prom-client/lib/metrics/processStartTime.js:4
1 | 'use strict';
2 |
3 | const Gauge = require('../gauge');
> 4 | const nowInSeconds = Math.round(Date.now() / 1000 - process.uptime());
5 |
6 | const PROCESS_START_TIME = 'process_start_time_seconds';
7 |
View compiled
./node_modules/prom-client/lib/metrics/processStartTime.js
解决方案
似乎您正在创建一个react.js应用程序,而不是一个node.js服务器应用程序。
当node.js是服务器端时, react是前端。
没有process.uptime()
,因为没有涉及node.js服务器。
prometheus.io库不提供react客户端。
推荐阅读
- sql - 检索每个组中的最后一条记录
- javascript - 我如何重写此代码以使对象从画布顶部掉落,并且当它触到底部时它会在顶部重置
- javascript - bootstrapSwitch 不要在点击时切换开关
- vb.net - 我的 GetSalesTax 函数没有返回我需要的内容,因此我可以显示值
- ios - ARC 语义问题 - 选择器没有已知的实例方法
- python - Pandas 是 Column 中的字符串
- reactjs - 在另一个组件中使用一个组件来渲染道具
- racket - 将 char 列表转换为单个字符串
- mysql - Mysql 查询浏览器不显示模式(数据库)
- c# - 为什么当用户处于正确角色时显示拒绝访问?