github上这个项目没有告知需要npm版本2.1.2 node>8,所以写下这个避免踩坑 系统版本:centos 6系列

yum install epel-release npm wget -y npm config set strict-ssl false #有时候会提示根证书不信任,关掉这个省去麻烦 npm install npm@v2.1.2 -g #升级npm,-g代表直接替换旧版本

wget -O- https://raw.githubusercontent.com/aliyun-node/tnvm/master/install.sh | bash export METHOD=script source /root/.bashrc tnvm install node-v8.9.4 tnvm use node-v8.9.4

注:利用tnvm升级node,注意npm先升级,不然先node再npm,node会回到旧版本

npm install node-media-server node app.js

npm install --save body-parser #这个是执行node app.js报缺少这个body-parser模块的时候执行,同理适用于其他模块

附:app.js示例

const NodeMediaServer = require('node-media-server');

const config = { rtmp: { port: 1935, chunk_size: 60000, gop_cache: true, ping: 30, ping_timeout: 60 }, http: { port: 8000, mediaroot: './media', allow_origin: '*' }, relay: { ffmpeg: '/root/nms/ffmpeg', tasks: [ { app: 'mv', mode: 'static', edge: '/root/test.flv', name: 'dq' } ] } }

var nms = new NodeMediaServer(config) nms.run();