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

Created on 27 Aug 2017  ·  18Comments  ·  Source: OpenZeppelin/openzeppelin-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

Most helpful comment

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

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

All 18 comments

Can you try installing OpenZeppelin locally (instead of globally)? I agree that this should work but it seems to be a problem with Truffle not considering global node modules. We should report this to the Truffle project if it hasn't already been reported.

Same issue for me too(Error: Could not find zeppelin-solidity/contracts/token/MintableToken.sol). I installed OpenZeppelin locally

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

same issue for me too if any one find answer please let us know

@sh4ka no, I tried that too. Did not work.

@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.

I have the same problem.

"->'
and
import '../../node_modules/zeppelin-solidity/contracts/token/MintableToken.sol'

did not help

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

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

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

Truffle doesn't find the global module. I fixed this way:

In the project folder:
_npm init_

// Install the zeppelin-solidity module locally
_npm install zeppelin-solidity_

// Then compile
_truffle compile_

想知道有多少人碰到这个问题是因为从网上抄过时的代码导致的,正如@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.

@chenyulzhh 你是个天才!这个totalSupply_后面加个下划线,目的是?

@hiyouke 因为BasicToken类里面,定义的是 totalSupply_ ,估计是为了和 totalSupply() 这个public的方法区分开吧。。

remove openzeppelin to zepplin that worked for me

Please check zeppeline / openzeppelin version and then check corresponding node_module folder whether mentioned module file is available or not else change your import path

Could not find openzeppelin/contracts/ownership/Ownable.sol from any sources;

can anyone resolve it?

For anyone who is having this issue, we're happy to help, but there are many potential causes so we need to know more details about your environment, your dependencies, etc.

Please share all of this information in a new post at forum.openzeppelin.com and we'll help you figure it out.

Was this page helpful?
0 / 5 - 0 ratings