Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kkagill opened this issue Mar 19, 2021 · 8 comments
Open

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

kkagill opened this issue Mar 19, 2021 · 8 comments
Labels
bug Something isn't working

Comments

@kkagill
Copy link

kkagill commented Mar 19, 2021

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

@PaulRBerg
Copy link
Collaborator

PaulRBerg commented Mar 19, 2021

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.

@kkagill
Copy link
Author

kkagill commented Mar 19, 2021

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

@PaulRBerg
Copy link
Collaborator

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 PaulRBerg reopened this Mar 20, 2021
@kkagill
Copy link
Author

kkagill commented Mar 22, 2021

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)

@PaulRBerg
Copy link
Collaborator

Thanks for the info! Will investigate further.

@PaulRBerg PaulRBerg added the bug Something isn't working label Apr 21, 2021
@joshuabyler
Copy link
Contributor

joshuabyler commented May 25, 2021

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.

@refex
Copy link

refex commented May 22, 2022

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

@PaulRBerg
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants