$ npm install -g truffle npm ERR! code EEXIST错误解决方法

 安个truffle折磨了我好几天 今天终于安装好了 翻了好多博客都没找到答案 是我读出错信息解决的 由此可见 出错信息还是不易忽视的

$ npm install -g truffle
npm ERR! code EEXIST
npm ERR! path E:\software\nn\node.js\node_global\node_modules\truffle\build\cli.bundled.js
npm ERR! dest E:\software\nn\node.js\node_global\truffle.cmd
npm ERR! EEXIST: file already exists, cmd shim 'E:\software\nn\node.js\node_global\node_modules\truffle\build\cli.bundled.js' -> 'E:\software\nn\node.js\node_global\truffle.cmd'
npm ERR! File exists: E:\software\nn\node.js\node_global\truffle.cmd
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.

npm ERR! A complete log of this run can be found in:
npm ERR!     E:\software\nn\node.js\node_cache\_logs\2020-02-06T14_02_17_324Z-debug.log

(敲黑板)

以上错误是node_global文件下的truffle.cmd文件已经存在 需要删除

$ npm install -g truffle
npm ERR! code EEXIST
npm ERR! path E:\software\nn\node.js\node_global\node_modules\truffle\build\cli.bundled.js
npm ERR! dest E:\software\nn\node.js\node_global\truffle
npm ERR! EEXIST: file already exists, cmd shim 'E:\software\nn\node.js\node_global\node_modules\truffle\build\cli.bundled.js' -> 'E:\software\nn\node.js\node_global\truffle'
npm ERR! File exists: E:\software\nn\node.js\node_global\truffle
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.

npm ERR! A complete log of this run can be found in:
npm ERR!     E:\software\nn\node.js\node_cache\_logs\2020-02-07T07_24_49_045Z-debug.log

然后又出现

了新的错误 我都不知道为什么会有这么多装错地方的文件

这个错误的意思是node_global文件下的truffle文件已经存在 需要删除

$ npm install -g truffle
E:\software\nn\node.js\node_global\truffle -> E:\software\nn\node.js\node_global\node_modules\truffle\build\cli.bundled.js

> [email protected] postinstall E:\software\nn\node.js\node_global\node_modules\truffle
> node ./scripts/postinstall.js

- Fetching solc version list from solc-bin. Attempt #1
√ Downloading compiler. Attempt #1.
+ [email protected]
added 27 packages from 439 contributors in 361.036s

这样就安装成功了

别忘了检验一下

$ truffle -v
Truffle v5.1.12 - a development framework for Ethereum

Usage: truffle  [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 (experimental)
  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安装错误)