node js npm grunt安装,elasticsearch-head 5.X安装

来源:互联网 发布:ubuntu efi系统分区 编辑:程序博客网 时间:2024/05/21 02:51

安装时候,记得使用root用户

1.linux系统

fox.风

1.1 方式一 下载编译后安装包安装

下载地址

https://nodejs.org/en/download/

All download options选择这个链接(这个是已经编译好的,尽量不要自己编译,因为坑比较多)
或者Linux Binaries (x86/x64) 后面的64-bit(这个是xz压缩包)

这边选择的是如下(目前最新长期稳定版):

node-v6.10.0-linux-x64.tar.gz

下载方式按个人喜好 选一个
下载一(gz压缩包)

wget https://nodejs.org/dist/v6.10.0/node-v6.10.0-linux-x64.tar.gzmkdir -p /usr/local/nodetar  xf node-v6.10.0-linux-x64.tar.gzmv node-v6.10.0-linux-x64 /usr/local/node/

下载二(xz压缩包)

wget https://nodejs.org/dist/v6.10.0/node-v6.10.0-linux-x64.tar.xzxz -d node-v6.10.0-linux-x64.tar.xztar xvf node-v6.10.0-linux-x64.tarmkdir -p /usr/local/nodemv node-v6.10.0-linux-x64 /usr/local/node/

配置环境变量

本环境变量在 centos7.x ubuntu16.x以上 支持
如果你的系统没有/etc/profile.d目录,那么请mkdir -p /etc/profile.d命令新建目录,然后
vim /etc/profile文件中,最后一行 加入. /etc/profile.d/node.sh,保存退出,然后就可以继续执行下面命令了

vim /etc/profile.d/node.sh

加入

export NODE_PATH=/usr/local/node/node-v6.10.0-linux-x64export PATH=$NODE_PATH/bin:$PATH

应用

 . /etc/profile . /etc/bashrc

1.2 Ubuntu 系统

sudo apt-get install nodejssudo apt-get install npm

1.3 CentOS 系统

sudo yum install nodejssudo yum install npm

2.MAC 系统

2.1 方式一

brew install node

该命令执行后,node 和npm自动安装完成

查看版本

安装完成后就可以查看软件版本

#nodenode -v#npmnpm -v

grunt安装

npm install -g grunt-cli

案例 安装依赖

例如安装elasticsearch-head

elasticsearch-head

下载地址:https://github.com/mobz/elasticsearch-head
下载后解压

https://github.com/mobz/elasticsearch-head/archive/master.zip -O elasticsearch-head.zipunzip elasticsearch-head.zip

进入 elasticsearch-head-master目录
如果你的网速较快,可以使用这个命令,推荐使用后面一个命令

npm install

使用国内镜像

npm install -g cnpm --registry=https://registry.npm.taobao.org

修改Elasticsearch配置文件

这个是 另一个 程序,如果只是安装看看,这步可以忽略
编辑

vim elasticsearch-5.2.2/config/elasticsearch.yml

加入以下内容:

http.cors.enabled: truehttp.cors.allow-origin: "*"

修改Gruntfile.js

修改 elasticsearch-head-master/Gruntfile.js,在connect属性中,增加hostname: ‘0.0.0.0’

cd elasticsearch-head-master/vim Gruntfile.js

修改为

connect: {        server: {            options: {                hostname: '0.0.0.0',                port: 9100,                base: '.',                keepalive: true            }        }    } 

启动 elasticsearch-head

进入elasticsearch-head-master目录

cd elasticsearch-head-master#执行grunt server

输出

>> Local Npm module "grunt-contrib-jasmine" not found. Is it installed?Running "connect:server" (connect) taskWaiting forever...Started connect web server on http://localhost:9100

浏览器访问
http://localhost:9100

elasticsearch-head 设置后台启动和关闭

启动

进入elasticsearch-head-master目录

vim elasticsearch-head_start.sh

加入

#!/bin/bashecho "START elasticsearch-head "nohup grunt server &exit

关闭

#!/bin/bashecho "STOP elasticsearch-head "ps -ef |grep head|awk '{print $2}'|xargs kill -9

其他

npm、grunt、bower实现前端项目自动化
http://blog.csdn.net/wangnantjobj/article/details/53739409
案例部分(Elasticsearch 5.1.1 head插件安装)参考
http://blog.csdn.net/napoay/article/details/53896348

Q&A

grunt-cli: The grunt command line interface (v1.2.0)

grunt-cli: The grunt command line interface (v1.2.0)Fatal error: Unable to find local grunt.If you're seeing this message, grunt hasn't been installed locally toyour project. For more information about installing and configuring grunt,please see the Getting Started guide:http://gruntjs.com/getting-started

安装 grunt

npm install -g grunt
0 0
原创粉丝点击