openzeppelin-contracts: truffle compile error: could not find zeppelin-solidity/contracts/...

I can see zeppelin-solidity in the /usr/local/lib/node_modules on my mac. I created project with truffle init, but in one of my contracts, I cannot import the zeppelin contracts successfully.

pragma solidity 0.4.15;
import "zeppelin-solidity/contracts/token/MintableToken.sol";
contract SampleToken is MintableToken {
  string public name = "SampleToken";
  string public symbol = "SMT";
  uint256 public decimals = 1;
}

on truffle compile I get the following output:

Error: Could not find zeppelin-solidity/contracts/token/MintableToken.sol from any sources; imported from /Users/username/Develop/project/project-core/contracts/Tokens/SampleToken.sol
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:49111:23
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:60660:16
    at next (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:69109:18)
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:49099:7
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:96498:5
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:69014:16
    at replenish (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:60630:25)
    at iterateeCallback (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:60620:17)
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:60660:16
    at ReadFileContext.callback (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:96494:14)

the versions are: Truffle v3.4.9 npm 3.10.10 solcjs 0.4.15+commit.bbb8e64f.Emscripten.clang

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 18 (4 by maintainers)

Most upvoted comments

zeppelin-solidity changed directory structure in new version, it should be:

import 'zeppelin-solidity/contracts/token/ERC20/MintableToken.sol';

@roynalnaruto Can you try with single quotes instead? "->’

I resolved the same problem with: npm init so now the sequence is:

npm init truffle init npm install zeppelin-solidity truffle compile

hope it would helps

@roynalnaruto @param087: One solution that works for me until this will be fixed is to add also the node_modules folder to the relative path (after I installed the package locally of course 😃 ).

For example, instead of import 'zeppelin-solidity/contracts/token/MintableToken.sol' I did: import '../../node_modules/zeppelin-solidity/contracts/token/MintableToken.sol'

Can anyone having this issue please share an example repo where I can reproduce the problem? I suspect this was caused by doing a global install (npm install -g zeppelin-solidity) which Truffle doesn’t support.

I’ve opened an issue for it trufflesuite/truffle-resolver#4.

remove openzeppelin to zepplin that worked for me

想知道有多少人碰到这个问题是因为从网上抄过时的代码导致的,正如@hahaelx 所说的那样新版本zeppelin-solidity里 token目录下面新增了一层目录 ERC20

Sorry for my poor english,translated with Baidu:

I want to know how many people encounter this problem because of the outdated code from the Internet. As @hahaelx said, as a result of the new version of zeppelin-solidity, there is a new directory ERC20 under the token directory.