【问题标题】:Tried npm install -g truffle but getting this gyp error试过 npm install -g truffle 但得到这个 gyp 错误
【发布时间】:2022-02-15 19:03:50
【问题描述】:

我尝试了 npm node-gyp -g 但没有帮助。我正在尝试在我的 mac 中安装松露。我使用的是 mac os Catalina,node 版本 16.13.1,npm 版本 8.1.2

npm ERR! code 1
npm ERR! path /usr/local/lib/node_modules/truffle/node_modules/ganache/node_modules/leveldown
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
npm ERR! CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-1.20/db/builder.o
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.3.0
npm ERR! gyp info using node@16.13.1 | darwin | x64
npm ERR! gyp info find Python using Python version 3.8.1 found at "/Library/Frameworks/Python.framework/Versions/3.8/bin/python3"
npm ERR! gyp info spawn /Library/Frameworks/Python.framework/Versions/3.8/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/truffle/node_modules/ganache/node_modules/leveldown/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-/c++/v1/string:505:
...
npm ERR! gyp ERR! System Darwin 19.6.0
npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /usr/local/lib/node_modules/truffle/node_modules/ganache/node_modules/leveldown
npm ERR! gyp ERR! node -v v16.13.1
npm ERR! gyp ERR! node-gyp -v v8.3.0
npm ERR! gyp ERR! not ok

【问题讨论】:

    标签: node.js npm web3 truffle


    【解决方案1】:

    请参阅https://github.com/trufflesuite/truffle/issues/4692,因此对于解决方法,我们必须...

    对于非 nvm

    # Install npm 6
    npm i -g npm@6
    
    # Make sure should get npm `6.14.15`
    npm --version
    
    # Should work now
    npm i -g truffle
    

    对于非虚拟机

    # In case you have 16 installed (you can skip this)
    npm config delete prefix
    
    # Get npm 6.14.16 from node 14 (or you can try install only npm)
    nvm use 14
    
    # Make sure should get npm `6.14.15`
    npm --version
    
    # Should work now
    npm i -g truffle
    

    【讨论】:

      猜你喜欢
      • 2017-04-05
      • 2021-11-01
      • 2017-02-02
      • 1970-01-01
      • 1970-01-01
      • 2021-08-25
      • 1970-01-01
      • 2016-05-29
      • 2018-05-08
      相关资源
      最近更新 更多