概述
安装时候,记得使用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
最后
以上就是英俊手链为你收集整理的node js npm grunt安装,elasticsearch-head 5.X安装1.linux系统2.MAC 系统2.1 方式一查看版本grunt安装案例 安装依赖其他Q&A的全部内容,希望文章能够帮你解决node js npm grunt安装,elasticsearch-head 5.X安装1.linux系统2.MAC 系统2.1 方式一查看版本grunt安装案例 安装依赖其他Q&A所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复