Solc

npm install -g solc 時出現錯誤

  • December 19, 2018

嘗試使用安裝 solc 時出現錯誤

npm install -g solc

這是錯誤:

erfans-MacBook-Pro:01 erfanandesta$ npm uninstall -g solc
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/solc
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/solc/node_modules
npm ERR! path /usr/local/lib/node_modules/solc
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules/solc'
npm ERR!  { [Error: EACCES: permission denied, access '/usr/local/lib/node_modules/solc']
npm ERR!   stack:
npm ERR!    "Error: EACCES: permission denied, access '/usr/local/lib/node_modules/solc'",
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules/solc' }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/erfanandesta/.npm/_logs/2018-12-06T07_44_32_823Z-debug.log

當我使用sudo npm install -g solc它成功安裝時,我現在收到此錯誤:

internal/modules/cjs/loader.js:605
   throw err;
   ^

Error: Cannot find module './smtchecker.js'
   at Function.Module._resolveFilename (internal/modules/cjs/loader.js:603:15)
   at Function.Module._load (internal/modules/cjs/loader.js:529:25)
   at Module.require (internal/modules/cjs/loader.js:658:17)
   at require (internal/modules/cjs/helpers.js:22:18)
   at Object.<anonymous> (/usr/local/lib/node_modules/solc/solcjs:9:18)
   at Module._compile (internal/modules/cjs/loader.js:722:30)
   at Object.Module._extensions..js (internal/modules/cjs/loader.js:733:10)
   at Module.load (internal/modules/cjs/loader.js:620:32)
   at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
   at Function.Module._load (internal/modules/cjs/loader.js:552:3)

這不是solc相關的錯誤。請改用以下命令:

sudo npm install -g solc

在全域安裝它時,您需要提供足夠的權限。

EDIT1: 關於smtchecker錯誤,它似乎缺少這個文件:https ://github.com/ethereum/solc-js/blob/master/smtchecker.js

將它放在你的solcjs封包件夾中的正確位置,它應該可以工作。

雖然這是一種解決方法,但不是正常解決方案,因為這似乎是solc. 我已經提出了關於這個的問題,可以在這里關注:https ://github.com/ethereum/solc-js/issues/324

引用自:https://ethereum.stackexchange.com/questions/63676