Truffle的安裝


Truffle安裝環境要求:

  1. python
  2. solc
  3. testrpc
  4. node.js
  5. git
  6. g++
  7. npm
  8. libssl-dev
  9. nvm

使用NVM安裝Node.js和npm

1 curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
2 nvm –version
3 nvm install node
4 node –version
5 sudo apt install build-essential

Truffle安裝需要NodeJS v8.9.4 or later。

使用下面的命令可以安裝最新版本NodeJS。

 1 sudo apt remove --purge nodejs npm
 2 sudo apt clean
 3 sudo apt autoclean
 4 sudo apt install -f
 5 sudo apt autoremove
 6 sudo apt install curl
 7 curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
 8 sudo apt-get install -y nodejs
 9 curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
10 sudo apt-get update && sudo apt-get install yarn
11 
12 npm -version
13 6.1.0
14 nodejs -v
15 v10.7.0

安裝指定版本的solidity

1 # 最簡單的安裝方法,沒有辦法指定版本
2 sudo add-apt-repository ppa:ethereum/ethereum
3 sudo apt-get update
4 sudo apt-get install solc
5 # 指定版本
6 sudo apt install linuxbrew-wrapper
7 brew install solidity@0.5.0

正式安裝:

Truffle安裝命令很簡單: npm install -g truffle 

我出現了錯誤, code:127,sh: 1: node-gyp: Permission denied 

解決方法:安裝命令改為: sudo npm install --unsafe-perm --verbose truffle -g 

安裝成功。

網上也會有其他的解決方法,但是對我的安裝過程沒有作用,我在下方列出。

# 第一種
npm config set user 0
npm config set unsafe-perm true

# 第二種
npm config set registry https://registry.npm.taobao.org

使用過程:

  • truffle compile、truffle migrate不報錯也不生成build

    命令改為sudo truffle compile

  • testrpc啟動報端口錯誤,geth客戶端就是8545端口。

    lsof -i:8545;kill -9 <process_id>

參考文章:

https://www.myfreax.com/how-to-install-node-js-on-ubuntu-18-04/

https://github.com/Trufflesuite/Truffle

https://blog.csdn.net/weixin_42608885/article/details/95461391

https://www.trufflesuite.com/docs/truffle/reference/configuration

https://blog.csdn.net/u010304442/article/details/89883931


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM