DEV Community

Discussion on: How to Build a Full Stack NFT Marketplace - V2 (2022)

Collapse
 
ayumirage profile image
Ayumirage • Edited

im stuck on this error:

./pages/index.js:10:0
Module not found: Can't resolve '../artifacts/contracts/Market.sol/NFTMarket.json'
8 |
9 | import NFT from "../artifacts/contracts/NFT.sol/NFT.json";

10 | import Market from "../artifacts/contracts/Market.sol/NFTMarket.json";
11 |
12 | export default function Home() {
13 | const [nfts, setNfts] = useState([]);

Collapse
 
btandayamo profile image
Bertil Tandayamo

Please elaborate

Collapse
 
sumeetchawla profile image
Sumeet Chawla

If you are running on local, you haven't compiled or tested your code and hence the artifacts are not generated.

If you are trying to build on vercel, this will come cause again the artifacts are missing. The general practice is not to commit those. Add a compile (or test) command to your build script before building nextjs.

Collapse
 
barryhewitt profile image
Baz-Cloud

Hi, please could you help me with this, i've been following this course for days now and I'm totally stuck on this.

Once i type npm run dev this is what i get

BarryH@EPT-LT23 MINGW64 ~/digital-marketplace (main)
$ npm run dev

digital-marketplace@0.1.0 dev
next dev

ready - started server on 0.0.0.0:3000, url: localhost:3000
info - Using webpack 5. Reason: Enabled by default nextjs.org/docs/messages/webpack5
event - compiled successfully
event - build page: /
wait - compiling...
error - ./pages/index.js:11:0
Module not found: Can't resolve '../artifacts/contracts/Market.sol/NFTMarket.json'
9 |
10 | import NFT from '../artifacts/contracts/NFT.sol/NFT.json'

11 | import Market from '../artifacts/contracts/Market.sol/NFTMarket.json'
12 |
13 | export default function Home() {
14 | const [nfts, setNfts] = useState([])

Import trace for requested module:

nextjs.org/docs/messages/module-no...
event - build page: /next/dist/pages/_error
wait - compiling...
error - ./pages/index.js:11:0
Module not found: Can't resolve '../artifacts/contracts/Market.sol/NFTMarket.json'
9 |
10 | import NFT from '../artifacts/contracts/NFT.sol/NFT.json'

11 | import Market from '../artifacts/contracts/Market.sol/NFTMarket.json'
12 |
13 | export default function Home() {
14 | const [nfts, setNfts] = useState([])

Import trace for requested module:

nextjs.org/docs/messages/module-no...
wait - compiling...
event - compiled successfully

Collapse
 
vitustockholm profile image
Vitus

change => '../artifacts/contracts/Market.sol/NFTMarket.json' to ...... '../artifacts/contracts/NFTMarket.sol/NFTMarket.json'

Collapse
 
barryhewitt profile image
Baz-Cloud

Hi, i'm really stuck on this and have been trying to figure it out for hours, did you manage to figure it out?

Collapse
 
vitustockholm profile image
Vitus

hm, did You try figure out this: '' error - ./pages/index.js:11:0 '' *** index.js 11 code line

time is the master , and time could be disaster .. .
for me worked good enough to go and make tests :

' 'change => '../artifacts/contracts/Market.sol/NFTMarket.json' to ...... '../artifacts/contracts/NFTMarket.sol/NFTMarket.json' ''

Thread Thread
 
mendsalbert profile image
Mends Albert

After a couple of hours of digging I finally found the solution to this problem

  1. The 'artefacts' directory is included in the .gitignore file which makes the whole folder invisible during build
  2. open the gitignore file and exclude the artefacts directory
  3. Now run 'npm run build' and everything all the error will be gone