玩Deno遇到問題的解決方案

adherent發表於2018-06-02

最近有個新的Deno專案是由node原作者ry發起的,瞬間火爆,star數飛起。 但是在搭建環境的過程中還是有些小問題,但是在友好的issue下都得到了解決! 再此總結,並對那些在issue裡無私貢獻自己解決方案的人點贊!開源社群的和諧需要大家去一起努力。

附上專案地址: GitHub - ry/deno: A secure TypeScript runtime on V8

Step1

在開始之前請準備好vpn*。 大家需要去安裝 Go 環境.並且去 export 各種Go相關的環境變數.

以下是方正大佬給我提供解決方案,很感謝。 https://github.com/ry/deno/issues/92 Mac OS可以參考以下:

export GOROOT=/usr/local/go # where your `go` sitting, usually here ( Mac )
export GOPATH=$HOME/go # means `~/go` 
export PATH=$PATH:$HOME/go/bin:$GOPATH/bin
複製程式碼

如果是Mac的話,我們還需要去安裝xcode-select http://osxdaily.com/2014/02/12/install-command-line-tools-mac-os-x/

我們還需要安裝Protobuf 。Ubuntu下:

cd ~
wget https://github.com/google/protobuf/releases/download/v3.1.0/protoc-3.1.0-linux-x86_64.zip
unzip protoc-3.1.0-linux-x86_64.zip
export PATH=$HOME/bin:$PATH
複製程式碼

Mac下簡單粗暴: brew install protobuf 再來裝一個README中沒提及的 brew install pkg-config

Step2

Ok以上一切正常,沒出啥么蛾子。 我們繼續,現在需要 protoc-gen-gogo-bindata:

go get -u github.com/golang/protobuf/protoc-gen-go
go get -u github.com/jteeuwen/go-bindata/...
複製程式碼

這步需要等一小夥,記得一定要vpn啊!

Step3

現在我們來困難重重的 v8worker2 啦。我們需要get 然後 build 它。大概會花30min

go get -u github.com/ry/v8worker2
cd $GOPATH/src/github.com/ry/v8worker2
./build.py --use_ccache
複製程式碼

接下來大家可能遇到的情況:

玩Deno遇到問題的解決方案
這種情況說明我們 clone 下的v8是有損壞的,然後我們需要做以下操作 1.

cd $GOPATH/src/github.com/ry/v8worker2
rm -rf v8
git clone https://github.com/v8/v8.git
cd v8
git checkout fe12316ec4b4a101923e395791ca55442e62f4cc
複製程式碼

或者 2.

export PATH=$PATH:$GOPATH/src/github.com/ry/v8worker2/depot_tools
cd $GOPATH/src/github.com/ry/v8worker2
rm -rf v8
fetch v8
cd v8
git checkout fe12316
複製程式碼

因為用第一種方法我發現我的vpn不能快速的下載所以就嘗試了第二種方法。如果你鍵入fetch發現命令列出現command not found: fetch。 你可以嘗試

cd $GOPATH/src/github.com/ry/v8worker2
depot_tools/./fetch v8
複製程式碼

感謝 go get v8worker2 Direct fetching of that commit failed? · Issue #92 · ry/deno · GitHub 下面給出解決方案的人@wbgbg ,@qti3e,@ztplz

如果你發現自己的depot_tools資料夾下啥都沒有。你需要執行以下命令

cd $GOPATH/src/github.com/ry/v8worker2
git submodule update --init
複製程式碼

之後再去

cd $GOPATH/src/github.com/ry/v8worker2
./build.py
複製程式碼

你看見了以下,那麼就恭喜啦!他在編譯了

玩Deno遇到問題的解決方案

Step4

最後一步

go get -u github.com/ry/deno/...
cd $GOPATH/src/github.com/ry/deno
make # 稍等片刻
./deno testdata/001_hello.js # Output: Hello World
複製程式碼

又是熟悉的Hello World! 在go get -u github.com/ry/deno/...遇到以下問題不要急,直接make deno走你! deno/dispatch.go:10:26: undefined: BaseMsg · Issue #71 · ry/deno · GitHub

$ go get  -u github.com/ry/deno/...
# github.com/ry/deno
../deno/dispatch.go:10:26: undefined: BaseMsg
../deno/dispatch.go:30:10: undefined: BaseMsg
../deno/dispatch.go:62:14: undefined: BaseMsg
../deno/dispatch.go:68:34: undefined: Msg
../deno/dispatch.go:119:13: select case must be receive, send or assign recv
../deno/fetch.go:13:11: undefined: Msg
../deno/fetch.go:16:8: undefined: Msg_FETCH_REQ
../deno/fetch.go:29:14: undefined: Msg
../deno/main.go:38:15: undefined: Asset
../deno/main.go:110:19: undefined: Msg
../deno/main.go:110:19: too many errors
複製程式碼

如果你在這make deno遇到了以下問題,說明你第一步方正大佬給出的解決方案還沒做。回去乖乖配置吧!

玩Deno遇到問題的解決方案

完成!

玩Deno遇到問題的解決方案

還有別的問題可以看以下issue: when I run ./build.py —use_ccache ,there was a mistake · Issue #60 · ry/deno · GitHub

相關文章