create-eth-app icon indicating copy to clipboard operation
create-eth-app copied to clipboard

Module not found: Can't resolve '@project/contracts'

Open kkagill opened this issue 3 years ago • 8 comments

Thank you for awesome repo!

ran yarn react-app:start and it gave me

Module not found: Can't resolve '@project/contracts' in 'C:\Users\sejong\Desktop\etc\Dapp\my-eth-app\packages\react-app\src'

Seems like import statement import { addresses, abis } from "@project/contracts"; in App.js doesn't not recognize files in contracts folder.

Researched a bit, and says there's import restriction outside of src directory.

Not sure if it works for others :(

I'm using windows 10 vs code node.js version 12

kkagill avatar Mar 19 '21 05:03 kkagill

Hey @kkagill, the issue is that you changed the name of your contracts package. What is the value of the name field in your packages/contracts/package.json. file?

By default, the name is @project/contracts, but if you change it, you will have to also change all the places where it is used.

You can read about how yarn workspaces work here.

PaulRBerg avatar Mar 19 '21 10:03 PaulRBerg

@paulrberg Thanks for the reply. FYI, it was the fresh copy and nothing was changed. I guess it's windows related problem :(

kkagill avatar Mar 19 '21 20:03 kkagill

Oh, shoot! Reopening now.

Can you share the following information?

  • Specific version of Windows 10
  • Bit architecture (32 or 64 bit)
  • Yarn version

Also:

  1. Could you try clean your cache and see what happens? Via yarn cache clean.
  2. Did you run CEA within another node.js project (that is, if there is another package.json higher up in the file tree)

PaulRBerg avatar Mar 20 '21 10:03 PaulRBerg

Hi @paulrberg

Windows 10 Pro 64 bit Yarn version v1.22.10

  1. cleared cache and tried again but same error
  2. nope I ran the start command from the root (my-eth_app)

kkagill avatar Mar 22 '21 07:03 kkagill

Thanks for the info! Will investigate further.

PaulRBerg avatar Mar 22 '21 09:03 PaulRBerg

Was able to fix this, a bunch of different steps, and you kind of have to keep solving bugs as you go down.

Mine might not solve @kkagill 's issue, but it might help. Also, try and run yarn add in each of the main folders in packages

I am using the vue template, and yarn 2. The vue-cli is not completely compatible with yarn 2 so there are some issues that have to be resolved.

I added the following to .yarnrc.yml

  "@vue/cli-service@*":
    dependencies:
      "@vue/cli-plugin-babel": "*"
      "@vue/cli-plugin-eslint": "*"
  "vue-eslint-parser@*":
    dependencies:
      babel-eslint: "*"

package.json at the root of the project needs to have the following added via yarn add

    "@babel/core": "^7.14.3",
    "@vue/cli": "^4.5.13",
    "core-js": "^3.12.1",
    "eslint": "^7.27.0",
    "hash-js": "^1.0.3",
    "hash.js": "^1.1.7"
  }

You will still run into npm issues from vue-cli, so you'll have to go into the packages/vue-app and run npm i --save core-js and then you should be able to run yarn vue-app:serve from the project root.

joshuabyler avatar May 25 '21 15:05 joshuabyler

Is there a solution for this? Just installed the react default template and it throws the same errors on yarn react-app:start I'm on Windows 10 Pro 64bit, node LTS (16.13.0), yarn 1.22.18

refex avatar May 22 '22 15:05 refex

@refex does it work if you cd into the packages/react-app and then run yarn start?

PaulRBerg avatar May 22 '22 17:05 PaulRBerg