安装ganache-cli
https://www.jianshu.com/p/a47367da19cf

https://github.com/trufflesuite/ganache-cli

1.先下载nodejs安装包
http://nodejs.cn/download/
2.下载完成后上传服务器解压文件 /home/test/ganache
 sudo tar -xvf node-v16.13.2-linux-x64.tar.xz
3.重命名文件夹
mv node-v16.13.2-linux-x64  nodejs 
4.建立软连接
sudo ln -s /home/test/ganache/nodejs/bin/npm /usr/local/bin/
sudo ln -s /home/test/ganache/nodejs/bin/node /usr/local/bin/
5.查看版本确认是否安装成功
node -v
npm -v


npm list -g --查看npm所有全局安装的模块


参考连接:https://www.cnblogs.com/liuqi/p/6483317.html

 6.

安装完nodejs和node之后,安装ganache-cli

sudo npm install -g ganache-cli

执行安装ganache-cli提示:

npm WARN deprecated ganache-cli@6.12.2: ganache-cli is now ganache; visit https://trfl.io/g7 for details
/home/test/ganache/node/bin/ganache-cli -> /home/test/ganache/node/lib/node_modules/ganache-cli/cli.js

> keccak@3.0.1 install /home/test/ganache/node/lib/node_modules/ganache-cli/node_modules/keccak
> node-gyp-build || exit 0
> secp256k1@4.0.2 install /home/test/ganache/node/lib/node_modules/ganache-cli/node_modules/secp256k1
> node-gyp-build || exit 0

+ ganache-cli@6.12.2
added 101 packages from 182 contributors in 2.296s

 执行ganache-cli命令返回提示Command not found

原因:当前用户未配置环境变量

编辑当前用户目录下的隐藏文件.bashrc(执行ls看不到,需要执行ls -a


在用户目录下执行vim .bashrc进入编辑 

在最下面添加一行,路径为放置node的文件路径  

export PATH="/home/test/ganache/nodejs/bin/:$PATH"

保存退出后执行命令source ~/.bashrc,使其立即生效

7.修改环境变量成功后,查看ganache-cli安装情况

安装成功后,返回ganache-cli版本号和账户

参考连接:https://blog.csdn.net/lantian_no1/article/details/117752765npm安装cnpm、ganache-cli、truffle等后,使用它们时提示Command not found。需添加环境变量_lantian_no1的博客-CSDN博客

 

 

Logo

更多推荐