官网:https://trufflesuite.com/docs/truffle/getting-started/installation/

使用命令进行全局安装使用

npm install -g truffle

npm install -g truffle
⸨⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⸩ ⠧ idealTree:lib: sill idealTree buildDeps
⸨⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⸩ ⠧ idealTree:lib: sill idealTree buildDeps

linlin@linlin-i5:/workspace/blockchain/contract_on_goerli_using_infura$ npm install -g truffle
⸨#########⠂⠂⠂⠂⠂⠂⠂⠂⠂⸩ ⠧ idealTree:lib: timing idealTree:#root Completed in 1035ms
⸨#########⠂⠂⠂⠂⠂⠂⠂⠂⠂⸩ ⠧ idealTree:lib: timing idealTree:#root Completed in 1035ms

linlin@linlin-i5:/workspace/blockchain/contract_on_goerli_using_infura$ npm install -g truffle
⸨#########⠂⠂⠂⠂⠂⠂⠂⠂⠂⸩ ⠙ idealTree:pouchdb-debug: sill fetch manifest express@^4.17.1

运行会一直卡着,那么就不使用这个命令 ,停止这个命令然后直接在AppStore进行搜索,进行安装即可

安装结束,直接在命令行进行使用命令查看版本号即可:truffle -v

linlin@linlin-i5:/workspace/blockchain/contract_on_goerli_using_infura$ truffle -v
Truffle v4.0.1 - a development framework for Ethereum

Usage: truffle <command> [options]

Commands:
  init      Initialize new Ethereum project with example contracts and tests
  compile   Compile contract source files
  migrate   Run migrations to deploy contracts
  deploy    (alias for migrate)
  build     Execute build pipeline (if configuration present)
  test      Run Mocha and Solidity tests
  debug     Interactively debug any transaction on the blockchain (experimental)
  opcode    Print the compiled opcodes for a given contract
  console   Run a console with contract abstractions and commands available
  develop   Open a console with a local TestRPC
  create    Helper to create new contracts, migrations and tests
  install   Install a package from the Ethereum Package Registry
  publish   Publish a package to the Ethereum Package Registry
  networks  Show addresses for deployed contracts on each network
  watch     Watch filesystem for changes and rebuild the project automatically
  serve     Serve the build directory on localhost and watch for changes
  exec      Execute a JS module within this Truffle environment
  unbox     Unbox Truffle project
  version   Show version number and exit

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

安装后,进行卸载,然后继续执行命令

npm uninstall -g truffle
npm install -g truffle

npm install -g truffle
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 har-validator@5.1.5: this library is no longer supported
npm WARN deprecated multicodec@1.0.4: This module has been superseded by the multiformats module
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated uuid@3.3.2: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated multibase@0.6.1: This module has been superseded by the multiformats module
npm WARN deprecated multibase@0.7.0: This module has been superseded by the multiformats module
npm WARN deprecated multicodec@0.5.7: This module has been superseded by the multiformats module
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 cids@0.7.5: This module has been superseded by the multiformats module
npm WARN deprecated uuid@3.2.1: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated uuid@2.0.1: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated uuid@3.2.1: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
⸨##################⸩ ⠧ reify:isarray: http fetch GET 200 https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz 6209ms (cache miss)

added 547 packages, and audited 579 packages in 3m

90 packages are looking for funding
  run `npm fund` for details

10 moderate severity vulnerabilities

To address issues that do not require attention, run:
  npm audit fix

Some issues need review, and may require choosing
a different dependency.

Run `npm audit` for details.
Reshimming asdf nodejs...

没有用的,还是安装回来吧。npm install之后,就可以使用truffle init了。