EatTheBlocks Forum

Migration issues due to failing import function


I am following the tutorial on the Bonus1:Defi for Dai tutorial. I am having problems when running the command “migrate --reset” on “truffle develop”.

The error tells me that my import statement wasnt working is shown below.

Compiling your contracts…

Error: Could not find @openzeppelin/contracts/token/ERC20/ERC20Detailed.sol from any sources; imported from C:\Users\yu\Desktop\test\defi\dai\contracts\Dai.sol
at Resolver. (C:\Users\yu\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\resolver\dist\lib\resolver.js:53:1)
at ()
at fulfilled (C:\Users\yu\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\resolver\dist\lib\resolver.js:5:42)

This below are the contents of my Dai.sol file, I have removed all the unneccessary code, because I think only the import statement has issues.

pragma solidity ^0.5.0;
import ‘@openzeppelin/contracts/token/ERC20/ERC20.sol’;
import ‘@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol’;
contract Dai {

After some digging I think that that is because I do not have the correct folders inside node modules/@openzepplin/contracts/.

When I have the files crowdsale/lifecycle and ownership folders, the import and migrate works but when I have presets, it doesnt work.

I accidently included the folders when trying and it worked, but I have no idea how to install them in my package.json with openzeppelin(maybe my version is outdated) but when I used the most updated version of the openzeppelin I couldnt get it to work too.

This below is my package.json file

“name”: “dai”,
“version”: “1.0.0”,
“description”: “”,
“main”: “truffle-config.js”,
“directories”: {
“test”: “test”
“scripts”: {
“test”: “echo “Error: no test specified” && exit 1”
“keywords”: [],
“author”: “”,
“license”: “ISC”,
“dependencies”: {
@openzeppelin/contracts”: “^2.5.1”

Thanks for any help.

This issue has been fixed. The problem is that the tutorial was ran on openzeppelin 2.5.1, which works. What was installed when I used the cmd “npm install @drizzle/store @drizzle/react-plugin @drizzle/react-components” as demonstrated in the tutorial installed the version 3.0.2 which is the latest version, but did not have the modules required.


how did you install the correct version? and which version is correct?