create-eth-app
create-eth-app copied to clipboard
Module not found: Can't resolve '@project/contracts'
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
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 Thanks for the reply. FYI, it was the fresh copy and nothing was changed. I guess it's windows related problem :(
Oh, shoot! Reopening now.
Can you share the following information?
- Specific version of Windows 10
- Bit architecture (32 or 64 bit)
- Yarn version
Also:
- Could you try clean your cache and see what happens? Via
yarn cache clean
. - Did you run CEA within another node.js project (that is, if there is another
package.json
higher up in the file tree)
Hi @paulrberg
Windows 10 Pro 64 bit Yarn version v1.22.10
- cleared cache and tried again but same error
- nope I ran the start command from the root (my-eth_app)
Thanks for the info! Will investigate further.
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.
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 does it work if you cd
into the packages/react-app
and then run yarn start
?