我无法在Mac上安装solc。我尝试了以下方法:
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,我跑
> eth.getCompilers()
[""]当我尝试setSolc时,发生了以下情况
> 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我试过遵循这里的指示,但它被卡住了
brew install llvm --HEAD --with-clang编辑:包括来自Mac中solc的package.json内容。
{
"_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"
}有什么想法吗?
发布于 2016-03-28 20:17:35
Ah...you使用这个错误。Web3教程没有反映出这一点,但是您在web3上使用构建自源代码编译器(这是web3假定的编译方式)和npm包(教程不围绕这两个包)进行编译的方式存在差异。为了进行编译,您需要按照Browser-solidity页面的说明进行操作:
https://github.com/chriseth/browser-solidity
节选:
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));
}https://ethereum.stackexchange.com/questions/2366
复制相似问题