温馨提示×

centos如何查nodejs配置

小樊
40
2026-09-27 00:46:45
栏目: 编程语言

在 CentOS 上查看 Node.js 相关配置,通常可以从以下几个方面入手,根据你的具体需求选择:


一、查看 Node.js 是否安装及版本

node -v
npm -v

或者:

which node
which npm

二、查看 Node.js 安装路径

which node
# 或
whereis node

如果是通过 nvm 安装的:

nvm which current

三、查看 npm 全局配置

npm config list

查看关键配置项:

npm config get prefix
npm config get registry
npm config get cache

修改示例(可选):

npm config set registry https://registry.npmmirror.com

四、查看 Node.js 运行环境变量

env | grep -i node

常见变量:

  • NODE_ENV
  • NODE_PATH
  • PATH

五、查看 Node.js 编译参数(源码安装时)

node -p process.config

六、查看系统服务中的 Node 配置(如 pm2 / systemd)

1. PM2

pm2 list
pm2 show <app_name>

2. systemd 服务

systemctl cat node-app.service

七、如果是通过 yum / dnf 安装

rpm -ql nodejs

八、查看 Node 进程实际使用的配置

ps aux | grep node

如果你能说明 具体想查哪类配置(例如:

  • 环境变量
  • npm 源
  • 服务启动参数
  • 性能 / 内存限制
  • 反向代理相关)

我可以给你更精确的命令。

0 踩