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

安装时候,记得使用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.gz
mkdir -p /usr/local/node
tar  xf node-v6.10.0-linux-x64.tar.gz
mv 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.xz
xz -d node-v6.10.0-linux-x64.tar.xz
tar xvf node-v6.10.0-linux-x64.tar
mkdir -p /usr/local/node
mv 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-x64
export PATH=$NODE_PATH/bin:$PATH

应用

 . /etc/profile
 . /etc/bashrc

1.2 Ubuntu 系统

sudo apt-get install nodejs
sudo apt-get install npm

1.3 CentOS 系统

sudo yum install nodejs
sudo yum install npm

2.MAC 系统

2.1 方式一

brew install node

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

查看版本

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

#node
node -v

#npm
npm -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.zip
unzip elasticsearch-head.zip

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

npm install

使用国内镜像

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

修改Elasticsearch配置文件

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

vim elasticsearch-5.6.1/config/elasticsearch.yml

加入以下内容:

http.cors.enabled: true
http.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) task
Waiting forever...
Started connect web server on http://localhost:9100

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

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

启动

进入elasticsearch-head-master目录

vim elasticsearch-head_start.sh

加入

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

关闭

#!/bin/bash
echo "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 to
your 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

Failed at the phantomjs-prebuilt@2.1.15 install script ‘node install.js’.

npm ERR! phantomjs-prebuilt@2.1.15 install: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the phantomjs-prebuilt@2.1.15 install script 'node install.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the phantomjs-prebuilt package,

解决方法

sudo npm install phantomjs-prebuilt@2.1.15 --ignore-scripts

参考:https://stackoverflow.com/questions/40992231/failed-at-the-phantomjs-prebuilt2-1-13-install-script-node-install-js

  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

风.foxwho

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值