欢迎光临
黎跃春区块链技术博客

【Truffle系列第1篇】3分钟搞定truffle安装

一、TRUFFLE 概述

Ethereum Virtual Machine (EVM)定制的世界一流的开发环境,可轻松用于区块链合约测试和项目管理,旨在简化开发人员的工作,使用truffle,您可以获得:

  • 内置的智能合约编译,链接,部署和二进制管理。
  • 自动化合约测试,方便快速开发。
  • 脚本的可编写化、可扩展的开发部署和迁移框架。
  • 用于部署到任意数量的公共和专用网络的网络管理。
  • 基于ERC190标准EthPM&NPM包管理。
  • 便捷化的合合通信交互式控制台。
  • 可配置的构建管道,支持紧密集成。
  • 外部脚本运行程序,在Truffle环境中执行脚本。

二、TRUFFLE 安装

2.1 安装前必备

  • NodeJS v8.9.4 或更高版本
  • Windows, Linux 或者 Mac OS X

2.2 TRUFFLE 安装

npm install -g truffle

安装时可能会出现如下错误:

(base) 黎跃春:~ liyuechun$ npm install -g truffle
npm WARN deprecated mkdirp@0.5.1: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!  [Error: EACCES: permission denied, access '/usr/local/lib/node_modules'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules'
npm ERR! }

上面的我们不难看出/usr/local/lib/node_modules没有访问权限,接下来我们执行如下命令:

(base) 黎跃春:~ liyuechun$ sudo chown -R $USER /usr/local/lib/node_modules
Password:

在这里,我们输入电脑密码,按下enter即可。

下一步,再次终端执行npm install -g truffle命令,如下所示:

(base) 黎跃春:~ liyuechun$ npm install -g truffle
npm WARN deprecated mkdirp@0.5.1: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
/usr/local/bin/truffle -> /usr/local/lib/node_modules/truffle/build/cli.bundled.js

> truffle@5.1.29 postinstall /usr/local/lib/node_modules/truffle
> node ./scripts/postinstall.js

- Fetching solc version list from solc-bin. Attempt #1
✔ Downloading compiler. Attempt #1.
+ truffle@5.1.29
added 27 packages from 439 contributors in 85.378s

到这一步,说明truffe已经安装成功,我们终端查询一下truffle的版本。

(base) 黎跃春:~ liyuechun$ truffle -v
Truffle v5.1.29 - a development framework for Ethereum

Usage: truffle <command> [options]

Commands:
  build     Execute build pipeline (if configuration present)
  compile   Compile contract source files
  config    Set user-level configuration options
  console   Run a console with contract abstractions and commands available
  create    Helper to create new contracts, migrations and tests
  debug     Interactively debug any transaction on the blockchain
  deploy    (alias for migrate)
  develop   Open a console with a local development blockchain
  exec      Execute a JS module within this Truffle environment
  help      List all commands or provide information about a specific command
  init      Initialize new and empty Ethereum project
  install   Install a package from the Ethereum Package Registry
  migrate   Run migrations to deploy contracts
  networks  Show addresses for deployed contracts on each network
  obtain    Fetch and cache a specified compiler
  opcode    Print the compiled opcodes for a given contract
  publish   Publish a package to the Ethereum Package Registry
  run       Run a third-party command
  test      Run JavaScript and Solidity tests
  unbox     Download a Truffle Box, a pre-built Truffle project
  version   Show version number and exit
  watch     Watch filesystem for changes and rebuild the project automatically

See more at http://truffleframework.com/docs

下一篇,我们一起来看看truffle如何快速上手使用。

赞(1) 打赏
未经允许不得转载:黎跃春区块链技术博客 » 【Truffle系列第1篇】3分钟搞定truffle安装

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

区块链在线课程、区块链职业技术水平认证考试一网打尽

区块链技术在线课程区块链技术职业认证

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏