提前条件
安装Nodejs? 可参考:Centos7 安装 Nodejs_ling1998的博客-CSDN博客
CentOS7安装
1、设置镜像
npm config set registry https://registry.npm.taobao.org
2、安装
注:加上版本号,否则一直报错
npm install -g truffle@5.1.13
不带版本号,一直卡在下面的位置不动?
[root@localhost truffle]# npm install -g truffle
The authenticity of host 'github.com (20.205.243.166)' can't be established.0
ECDSA key fingerprint is SHA256:p2QAMXNIC1TJYWeIOttrVc98/R1BUFWu3/LiyKgUfQM.
ECDSA key fingerprint is MD5:7b:99:81:1e:4c:91:a5:0d:5a:2e:2e:80:13:3f:24:ca.
Are you sure you want to continue connecting (yes/no)? ?###???????????????? ? idealTree:multiaddr: sill fetch manifest va?###???????????????? ? idealTree:multiaddr: sill fetch manifest varint@^5.0.0
?3、验证是否安装成功
[root@localhost bin]# truffle version
bash: truffle: command not found...
如出现上面错误,可参见进行解决:CentOS7 npm 安装完执行命令出现 bash: xxx: command not found..._ling1998的博客-CSDN博客
以下输出信息表示安装成功并可直接使用truffle了:?
[root@localhost truffle]# truffle version
Truffle v5.1.13 (core: 5.1.13)
Solidity v0.5.16 (solc-js)
Node v16.14.2
Web3.js v1.2.1
Windows安装
打开一个命令窗囗
1、设置镜像
C:\Users\Tracy>npm config set registry https://registry.npm.taobao.org
2、安装
注:加上版本号,否则会报错
C:\Users\Tracy>npm install -g truffle@5.1.13
?不带版本号,报一堆错误
C:\Users\Tracy>npm install -g truffle
npm WARN deprecated node-pre-gyp@0.11.0: Please upgrade to @mapbox/node-pre-gyp: the non-scoped node-pre-gyp package is deprecated and only the @mapbox scoped package will recieve updates in the future
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated mkdirp-promise@5.0.1: This package is broken and no longer maintained. 'mkdirp' itself supports promises now, please switch to that.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated circular-json@0.5.9: CircularJSON is in maintenance only, flatted is its successor.
npm WARN deprecated ipld-raw@6.0.0: This module has been superseded by the multiformats module
npm WARN deprecated ipld-dag-cbor@0.17.1: This module has been superseded by @ipld/dag-cbor and multiformats
npm WARN deprecated @nodefactory/filsnap-adapter@0.2.2: Package is deprecated in favour of @chainsafe/filsnap-adapter
npm WARN deprecated ipld-dag-pb@0.20.0: This module has been superseded by @ipld/dag-pb and multiformats
npm WARN deprecated multicodec@3.2.1: This module has been superseded by the multiformats module
npm WARN deprecated multibase@3.1.2: This module has been superseded by the multiformats module
npm WARN deprecated cids@1.1.9: This module has been superseded by the multiformats module
npm WARN deprecated axios@0.20.0: Critical security vulnerability fixed in v0.21.1. For more information, see https://github.com/axios/axios/pull/3410
# 略去后面的许多错误信息......
3、验证
C:\Users\Tracy>truffle version
Truffle v5.0.0 (core: 5.0.0)
Solidity v0.5.0 (solc-js)
Node v16.14.2
Windows安装很顺利,对应的目录已在安装Nodejs时已添加至环境变量中
|