nodejs官网
安装
CentOS、Fedora 和 Red Hat Enterprise Linux
Node.js 可作为nodejs在 CentOS/RHEL 8 和 Fedora 中调用的模块使用。
dnf module install nodejs:<stream># 查看Node.js 的主要版本。要查看可用流列表dnf module list nodejs# 安装12版本dnf module install nodejs:12
fs 文件操作
stat
获取文件状态
let fs = require("fs")fs.stat("./file.txt",function(error,stats){if(error){callback("file size error")}else{callback(stats)}})
加密
crypto
os
cpu信息
os.cpus()// 返回 object// model cpu名称// speed 速度// times <Object>//user <number> CPU 在用户模式下花费的毫秒数。//nice <number> CPU 在良好模式下花费的毫秒数。//sys <number> CPU 在系统模式下花费的毫秒数。//idle <number> CPU 在空闲模式下花费的毫秒数。//irq <number> CPU 在中断请求模式下花费的毫秒数
运行时长
os.uptime()// //返回系统的正常运行时间(以秒为单位)。
系统内存量
os.freemem()// 以整数的形式返回空闲的系统内存量(以字节为单位)
系统的内存总量
os.totalmem()//以整数的形式返回系统的内存总量(以字节为单位)。
系统类型
os.type()// 在 Linux 上返回 'Linux',在 macOS 上返回 'Darwin',在 Windows 上返回 'Windows_NT'
命令参数
# 版本node -v# --version# 在不执行的情况下,对脚本进行语法检查。node -c index.js# check
