我现在正在关注一个可靠性教程,当我运行松露迁移时,我正遇到一个错误。此外,testrpc正在另一个终端选项卡中运行,因此此问题与此处的其他问题无关。
我运行truffle init,然后将我的HelloWorld.sol智能合约添加到合约文件夹。
pragma solidity ^0.4.11;
contract HelloWorld {
uint public balance;
function HelloWorld(){
balance = 1000;
}
}
然后我运行松露编译,一切正常
Compiling ./contracts/ConvertLib.sol...
Compiling ./contracts/HelloWorld.sol...
Compiling ./contracts/MetaCoin.sol...
Compiling ./contracts/Migrations.sol...
Writing artifacts to ./build/contracts
然后我将以下内容添加到我的2_deploy_contracts.js迁移文件
中var HelloWorld = artifacts.require("./HelloWorld.sol");
module.exports = function(deployer) {
deployer.deploy(HelloWorld);
};
但是,当我运行松露迁移时,我收到以下错误:
Error: Cannot find module 'truffle-expect'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:85773:14)
at __webpack_require__ (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:21:30)
at Object.<anonymous> (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:59914:15)
at __webpack_require__ (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:21:30)
at Object.<anonymous> (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:201851:15)
at __webpack_require__ (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:21:30)
我已经尝试过npm安装truffle-expect,但这似乎也不起作用......有什么想法吗?
答案 0 :(得分:1)
1)运行以下命令:
npm install -g truffle-expect truffle-config web3
2)在另一个shell实例中运行testrpc
3)在松露项目目录中运行truffle migrate