1.安裝Homebrew
首先先安裝Homebrew,Homebrew簡稱brew,是Mac OSX上的軟件包管理工具,能在Mac中方便的安裝軟件或者卸載軟件,因爲不少開源的東西,蘋果沒有安裝源,可使用homebrew來管理安裝,因此在osx下安裝好homebrew仍是很方便的.html
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
2.node和npm的安裝:
https://nodejs.org/en/download/current/
到這個網址上尋找你須要的版本進行下載安裝便可,我選的是macOS installer(.pkg)前端
下載好,點擊打開就會出現這樣的界面,一路繼續就能夠了,沒有什麼很複雜的地方node
3.go安裝:
首先使用Homebrew安裝go:mysql
brew install go
而後查看:git
userMBP:loveToken user$ go version go version go1.10.1 darwin/amd64
沒能獲得go版本的緣由:
若是沒有成功,多是環境變量沒有設置好,你能夠經過運行github
export PATH=$PATH:/usr/local/opt/go/libexec/bin
來配置環境變量
這樣就能夠配置好環境了
若是想要進行go的代碼編寫並編譯的話,你須要給他指定一個專門的目錄$HOME/goweb
一開始的$PATH爲:sql
userMacBook-Pro:~ user$ $PATH -bash: ./usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home/bin:/usr/local/bin: No such file or directory
編輯.bash_profile文件,若是沒有請新建。在文件末尾加上:express
#GOPATH export GOPATH=$HOME/go #GOBIN export GOBIN=$GOPATH/bin export PATH=$PATH:$GOBIN
其中
- GOPATH: 平常開發的根目錄。
- GOBIN:是GOPATH下的bin目錄
而後查看bash_profile文件中內容:npm
userdeMacBook-Pro:~ user$ vi .bash_profile PATH=$PATH:/usr/local/bin export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion #GOPATH export GOPATH=$HOME/go #GOBIN export GOBIN=$GOPATH/bin export PATH=$PATH:$GOBIN ~ ~
編輯以後保存,而後執行source命令,使之生效:
userdeMacBook-Pro:~ user$ source .bash_profile
//查看path是否有改變
userMacBook-Pro:~ user$ $PATH -bash: ./usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home/bin:/usr/local/bin:/usr/local/bin:/Users/user/go/bin: No such file or directory
與上面獲得的$PATH對比,可見成功將go的路徑添加到了$PATH中
再查看go env得到更詳細的信息:
//成功安裝 userdeMacBook-Pro:~ user$ go env GOARCH="amd64" GOBIN="/Users/user/go/bin" GOCACHE="/Users/user/Library/Caches/go-build" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOOS="darwin" GOPATH="/Users/user/go" GORACE="" GOROOT="/usr/local/Cellar/go/1.10.1/libexec" GOTMPDIR="" GOTOOLDIR="/usr/local/Cellar/go/1.10.1/libexec/pkg/tool/darwin_amd64" GCCGO="gccgo" CC="clang" CXX="clang++" CGO_ENABLED="1" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/2_/g5wrlg3x75zbzyqvsd5f093r0000gn/T/go-build566845913=/tmp/go-build -gno-record-gcc-switches -fno-common」
4.geth
安裝步驟:https://github.com/ethereum/go-ethereum/wiki/Installation-Instructions-for-Mac
使用brew來下載geth了
brew tap ethereum/ethereum
brew install ethereum
而後就能夠經過geth--version來查看是否成功下載了
5.安裝Web3js:
npm install web3 -g
-g即全局變量
把npm下載了真的很方便,你會發現大多數的安裝均可以直接使用它
6.express
npm install express -g
7.Solidity
npm install -g solc
當你安裝了solc後,若是你想要查看它的信息的話,你要運行的語句是:
solcjs --help(而不是solc --help)
userdeMacBook-Pro:~ user$solcjs --version 0.4.21+commit.dfe3193c.Emscripten.clang
8.安裝sublime text3插件
8.1 > package control的安裝:點擊view-show console,而後輸入下面命令來安裝:
import urllib.request,os,hashlib; h = '6f4c264a24d933ce70df5dedcf1dcaeeebe013ee18cced0ef93d5f746d80ef60'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)
回車運行便可
安裝好後快捷鍵command + p便可出現package control
8.2 > Emmet插件——厲害,html設計時超好用
Emmet是很成熟的而且很是適用於編寫HTML/XML 和 CSS 代碼的前端開發工具,但也能夠用於編程語言
9.首先說說remix-ide是怎麼下載的:
Github上有教: https://github.com/ethereum/remix-ide
固然你也能夠不用下載而使用線上的remix的:
https://remix.ethereum.org/
下載即在終端運行:
npm install remix-ide -g
過程當中碰見的問題:
1》npm 發現用不了,是由於本地目錄下的.bash_profile中的path路徑寫的不是/usr/local/bin,由於這些東西安裝了都是放在這個路徑中的,這樣子以後連brew也均可以使用了,以前多是爲了使用mysql而改爲了mysql的路徑,把它改回來後就成功了
2》安裝
userdeMacBook-Pro:~ user$ npm install remix-ide -g
安裝remix-ide的時候出錯:
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/remix-ide npm ERR! path /usr/local/lib/node_modules/remix-ide npm ERR! code ENOENT npm ERR! errno -2 npm ERR! syscall access npm ERR! enoent ENOENT: no such file or directory, access '/usr/local/lib/node_modules/remix-ide' npm ERR! enoent This is related to npm not being able to find a file. npm ERR! enoent npm ERR! A complete log of this run can be found in: npm ERR! /Users/user/.npm/_logs/2018-06-28T07_51_08_260Z-debug.log
走到/usr/local/lib/node_modules/目錄下的時候發現以前是有安裝過這個的,因此有一個文件夾的名字也叫它,因此就試着把原文件夾直接刪掉,再安裝,就成功了
remix-ide的文件夾在目錄/user/usr/local/lib/node_modules/下
3》錯誤使用npm start來運行remix-ide其實直接remix-ide便可,npm start是使用的另外一種配置方式才須要的
userdeMacBook-Pro:~ user$ npm start
npm ERR! path /Users/user/package.json
因此須要在user這個目錄上使用npm init來生成package.json
4》運行remix-ide仍是出錯
而後就直接在終端中輸入remix-ide來打開本地的remix
userdeMacBook-Pro:~ user$ remix-ide internal/modules/cjs/loader.js:596 throw err; ^ Error: Cannot find module ‘./build/Release/scrypt'
解決
打開/usr/local/lib/node_modules/remix-ide/node_modules/scrypt/index.js將require(「./build/Release/scrypt")改成require("scrypt")
最後就成功了:
userdeMacBook-Pro:~ user$ remix-ide setup notifications for /Users/user Shared folder : /Users/user Starting Remix IDE at http://localhost:8080 and sharing /Users/user Thu Jun 28 2018 16:52:20 GMT+0800 (GMT+08:00) Remixd is listening on 127.0.0.1:65520 Thu Jun 28 2018 16:53:00 GMT+0800 (GMT+08:00) Received request for / Thu Jun 28 2018 16:53:00 GMT+0800 (GMT+08:00) Received request for /favicon.ico
此時在瀏覽器中輸入http://localhost:8080訪問就出來了
10.安裝truffle-4.1.5
sudo npm install -g truffle
11.安裝testrpc
npm install -g ethereumjs-testrpc
或者安裝ganache,二者中選一個,詳情看ganache與metamask