剛剛接觸truffle框架,上手實驗專案,結果truffle test 報錯,一頭霧水……
# 具體實作程序
truffle環境 +ganache(圖形化工具)

### 下面是操作程序

編譯,遷移合約程序無錯誤,日志正常!!!
然后執行truffle test 合約報錯
### 具體報錯
```
TestAdoptionPets
1) "before all" hook: prepare suite
0 passing (554ms)
1 failing
1) TestAdoptionPets
"before all" hook: prepare suite:
TypeError: Error parsing J:/truffle_workplace/AdoptionPets/bare-box/contracts/AdoptionPets.sol: Cannot destructure property `body` of 'undefined' or 'null'.
at getImports (C:\Users\11712\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\compile-solidity\profiler\getImports.js:5:1)
at findContracts.then.then (C:\Users\11712\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\compile-solidity\profiler\index.js:145:1)
```
##### 顯示報錯資訊為
**Cannot destructure property `body` of 'undefined' or 'null'**
uj5u.com熱心網友回復:
麻煩大佬幫忙看一下~~~~uj5u.com熱心網友回復:
我也碰到了這個問題,找不到答案uj5u.com熱心網友回復:
這個問題,對于后面的編譯和部署好像沒啥影響uj5u.com熱心網友回復:
看我的發的貼子,truffle版本問題uj5u.com熱心網友回復:
可能是truffle的版本和.sol檔案里面代碼的版本不符合,你看看合約里面是什么版本的?轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/25052.html
標籤:區塊鏈技術
上一篇:truffle安裝程序中卡死
