mac下bitshares-ui无法正常运行
bitshares-ui的README.md写得很简单,别人也很简单的执行即可,想不到我还得写篇文章来记录,在过程中碰到几处问题,其实网上也不少人碰到类似问题,记录一下。
npm install下载不动问题
现象:
要不就卡在下载,要不就下载超时,如下:
Downloading electron-v1.8.4-darwin-x64.zip
Error: connect ETIMEDOUT 54.231.49.80:443
Downloading electron-v1.8.4-darwin-x64.zip
[> ] 0.6% of 48.34 MB (3.18 kB/s)
解决方法:
先安装cnpm,然后用cnpm下载
Chaim:bitshares-ui Chaim$ npm install cnpm -g --registry=https://registry.npm.taobao.org
Chaim:bitshares-ui Chaim$ cnpm install
Module not found: Error: Can't resolve
现象:
ERROR in ./app/components/Wallet/WalletUnlockModal.jsx
Module not found: Error: Can't resolve 'react-foundation-apps/src/utils/foundation-api' in '/Users/Chaim/Documents/workspace/bitshares-ui/app/components/Wallet'
@ ./app/components/Wallet/WalletUnlockModal.jsx 12:0-67
@ ./app/App.jsx
@ ./app/Routes-dev.jsx
@ ./app/index-dev.js
@ ./app/Main-dev.js
@ multi react-hot-loader/patch webpack-hot-middleware/client ./app/Main-dev.js
解决方法:
Chaim:bitshares-ui Chaim$ cnpm install react-foundation-apps --save-dev
⠋ [react-foundation-apps@git+https://github.com/valzav/react-foundation-apps.git] install react-foundation-apps from git git+https://github.com/valzav/react-foundation-apps.git, may be very slow, please keep patience
✔ Installed 1 packages
✔ Linked 0 latest versions
✔ Run 0 scripts
✔ All packages installed (1 packages installed from git, used 5s, speed 0B/s, json 0(0B), tarball 0B)
can't resolve 的问题都用此方法解决。
Unexpected token
现象:
ERROR in ./node_modules/[email protected]@react-foundation-apps/src/trigger/index.jsx
Module parse failed: Unexpected token (59:13)
You may need an appropriate loader to handle this file type.
| render: function () {
| if (this.props.popupToggle) {
| return <PopupToggle {...this.props} />;
| } else {
| var child = React.Children.only(this.props.children);
@ ./app/components/DepositWithdraw/winex/WinexWithdrawModal.jsx 12:0-56
@ ./app/components/DepositWithdraw/winex/WinexGatewayRequest.jsx
@ ./app/components/DepositWithdraw/winex/WinexGateway.jsx
@ ./app/components/Account/AccountDepositWithdraw.jsx
@ ./app/Routes-dev.jsx
@ ./app/index-dev.js
@ ./app/Main-dev.js
@ multi react-hot-loader/patch webpack-hot-middleware/client ./app/Main-dev.js
解决方案:
又报这错误,查了很多资料,有说是node版本不对,升级到最新node9.6.1也一样,有说是babel-loader版本6.x.x不行要用5.x.x,装了5.0.0试一下,这个错误不报了又报其它的错误,哎~
Module build failed: ReferenceError:
ERROR in ./app/Main-dev.js
Module build failed: ReferenceError: [BABEL] /Users/Chaim/Documents/workspace/bitshares-ui/app/Main-dev.js: Unknown option: /Users/Chaim/Documents/workspace/bitshares-ui/.babelrc.presets
at Logger.error (/Users/Chaim/Documents/workspace/bitshares-ui/node_modules/[email protected]@babel-core/lib/transformation/file/logger.js:58:11)
解决方案:
还是安装nvm,从头来一遍吧!
sudo rm -rf /usr/local/lib/node_modules #删除全局 node_modules 目录
sudo rm /usr/local/bin/node #删除 node
cd /usr/local/bin && ls -l | grep "../lib/node_modules/" | awk '{print $9}'| xargs rm #删除全局 node 模块注册的软链
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.30.2/install.sh | bash
nvm install v6
nvm use v6
Module parse failed: Unexpected token
重新安装一遍还是同样的问题,nodejs这一套本来就不甚熟悉!
想了下整个过程,除了在npm install时用了cnpm install之外,没有任何不同,用npm install再安装一遍!
npm install报权限错误,sudo安装再试一遍:
localhost:bitshares-ui Chaim$ sudo npm install
localhost:bitshares-ui Chaim$ npm start
...
[458] ./node_modules/bitsharesjs/es/chain/src/TransactionBuilder.js 24.1 kB {0} [built]
+ 448 hidden modules
webpack: Compiled successfully.
居然成功了,真是不容易啊,也真丢人!
结论
可能与nodejs版本还是有关系,nvm install v6用的是6.14.1版本,开始一直是8.x、9.x版本测试都没成功。
以后应该严格遵照README做测试,因为自己机器用了比较久,各种资源和版本都比较多,不愿意动太大,想着在现有环境上弄成就得了,结果花的时间反而多了!
感谢您阅读 @chaimyu 的帖子,期待您能留言交流!
您这是专门研究birshares啊!
是的,刚开始,边熟悉边记录,多捧场~
一定一定,有机会我也研究研究
你好cn区点赞机器人 @cnbuddy 谢谢你对cn区的贡献。如果不想再收到我的留言,请回复“取消”。