wget https://github.com/nodejs/node/archive/v9.3.0.tar.gz
3.由于nodejs的编译需要 gcc/g++ 4.9.2以上,ubuntu14.04自带4.8.所有需要先更新到 gcc/g++ 4.9.2
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.9
sudo apt-get install g++-4.9
ln -s /usr/bin/g++-4.9 /usr/bin/g++ -f //修改链接,指向4.9
ln -s /usr/bin/gcc-4.9 /usr/bin/gcc -f //修改链接,指向4.9
4.编译并安装nodejs
cd ~/work/nodejsgit/node-9.3.0 //进入node代码目录 make //编译,等待一段较长时间
make install //安装
liao@ubuntu:~/work/nodejsgit/node-9.3.0$ node -v //查看node版本 v9.3.0
liao@ubuntu:~/work/nodejsgit/node-9.3.0$ npm -v //查看npm版本
5.5.1
5.安装truffle
npm install -g truffle
6.下载并安装ganache
wget https://github.com/trufflesuite/ganache/releases/download/v1.0.1/ganache-1.0.1-x86_64.AppImage //下载ganache
chmod +x ganache-1.0.1-x86_64.AppImage //修改权限
sudo ./ganache-1.0.1-x86_64.AppImage //启动ganache
root@ubuntu:/home/liao/work# ./ganache-1.0.1-x86_64.AppImage
liao@ubuntu:~/work$ mkdir myproject //新建一个工作目录
liao@ubuntu:~/work$ cd myproject/ //进入项目目录
liao@ubuntu:~/work/myproject$ truffle init //初始化Truffle 项目
liao@ubuntu:~/work/myproject$ ls //查看产生的文件
build contracts migrations test truffle-config.js truffle.js
liao@ubuntu:~/work/myproject$ cat truffle.js //修改配置文件后如下
module.exports = {
// See <http://truffleframework.com/docs/advanced/configuration>
// to customize your Truffle configuration!
networks: {
development: {
host: "127.0.0.1", //本地地址,ganache log中可看到
port: 7545, //端口,ganache log中可看到
network_id: "*" // Match any network id
}
}
};
liao@ubuntu:~/work/myproject$ truffle compile //编译
liao@ubuntu:~/work/myproject$ truffle migrate //跑migrate
Using network 'development'.
Network up to date.
mkdir MetaCoin
cd MetaCoin
truffle unbox metacoin
truffle compile
truffle migrate