首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法在Mac上安装solc

无法在Mac上安装solc
EN

Ethereum用户
提问于 2016-03-28 20:02:18
回答 1查看 3.5K关注 0票数 4

我无法在Mac上安装solc。我尝试了以下方法:

代码语言:javascript
复制
npm install solc 

/Users/punddalinni
└── solc@0.3.0-1 
npm WARN enoent ENOENT: no such file or directory, open '/Users/punddalinni/package.json'
npm WARN punddalinni No description
npm WARN punddalinni No repository field.
npm WARN punddalinni No README data
npm WARN punddalinni No license field.

当我回到geth,我跑

代码语言:javascript
复制
> eth.getCompilers()
[""]

当我尝试setSolc时,发生了以下情况

代码语言:javascript
复制
> admin.setSolc('/Users/punddalinni/node_modules/solc')
exec: "/Users/punddalinni/node_modules/solc": permission denied
    at InvalidResponse (<anonymous>:-81662:-57)
    at send (<anonymous>:-156322:-57)
    at setSolc (<anonymous>:-133322:-57)
    at <anonymous>:1:1

我试过遵循这里的指示,但它被卡住了

代码语言:javascript
复制
brew install llvm --HEAD --with-clang

编辑:包括来自Mac中solc的package.json内容。

代码语言:javascript
复制
{
  "_args": [
    [
      "solc",
      "/Users/punddalinni"
    ]
  ],
  "_from": "solc@latest",
  "_id": "solc@0.3.0-1",
  "_inCache": true,
  "_installable": true,
  "_location": "/solc",
  "_nodeVersion": "4.0.0",
  "_npmOperationalInternal": {
    "host": "packages-13-west.internal.npmjs.com",
    "tmp": "tmp/solc-0.3.0-1.tgz_1457892692634_0.5487515390850604"
  },
  "_npmUser": {
    "email": "d11e9@turkd.net",
    "name": "d11e9"
  },
  "_npmVersion": "3.3.2",
  "_phantomChildren": {},
  "_requested": {
    "name": "solc",
    "raw": "solc",
    "rawSpec": "",
    "scope": null,
    "spec": "latest",
    "type": "tag"
  },
  "_requiredBy": [
    "#USER"
  ],
  "_resolved": "https://registry.npmjs.org/solc/-/solc-0.3.0-1.tgz",
  "_shasum": "523e79db0c69070f91fcbf408e8c7d0c93be176c",
  "_shrinkwrap": null,
  "_spec": "solc",
  "_where": "/Users/punddalinni",
  "author": {
    "name": "chriseth"
  },
  "bugs": {
    "url": "https://github.com/chriseth/browser-solidity/issues"
  },
  "dependencies": {},
  "description": "Solidity compiler",
  "devDependencies": {},
  "directories": {},
  "dist": {
    "shasum": "523e79db0c69070f91fcbf408e8c7d0c93be176c",
    "tarball": "http://registry.npmjs.org/solc/-/solc-0.3.0-1.tgz"
  },
  "gitHead": "5ce686c8d33db78c8f1eb8e2318eefbc5151f0eb",
  "homepage": "https://github.com/chriseth/browser-solidity#readme",
  "keywords": [
    "compiler",
    "ethereum",
    "solidity"
  ],
  "license": "MIT",
  "main": "index.js",
  "maintainers": [
    {
      "name": "chriseth",
      "email": "c@ethdev.com"
    },
    {
      "name": "d11e9",
      "email": "d11e9@turkd.net"
    }
  ],
  "name": "solc",
  "optionalDependencies": {},
  "readme": "ERROR: No README data found!",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/chriseth/browser-solidity.git"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "version": "0.3.0-1"
}

有什么想法吗?

EN

回答 1

Ethereum用户

发布于 2016-03-28 20:17:35

Ah...you使用这个错误。Web3教程没有反映出这一点,但是您在web3上使用构建自源代码编译器(这是web3假定的编译方式)和npm包(教程不围绕这两个包)进行编译的方式存在差异。为了进行编译,您需要按照Browser-solidity页面的说明进行操作:

https://github.com/chriseth/browser-solidity

节选:

代码语言:javascript
复制
var solc = require('solc');
var input = "contract x { function g() {} }";
var output = solc.compile(input, 1); // 1 activates the optimiser

for (var contractName in output.contracts) {
    // code and ABI that are needed by web3
    console.log(contractName + ': ' + output.contracts[contractName].bytecode);
    console.log(contractName + '; ' + JSON.parse( output.contracts[contractName].interface));
}
票数 1
EN
页面原文内容由Ethereum提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://ethereum.stackexchange.com/questions/2366

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档