3

I'm following a YouTube video about NFT minting and when I enter this:

ts-node js/packages/cli/src/candy-machine-cli.ts upload ./assets --env devnet --keypair ~/.config/solana/devnet-test.json

I get the following error:

node:internal/modules/cjs/loader:936 throw err; ^

Error: Cannot find module './candy-machine-cli.ts' Require stack: at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15) at Function.resolve (node:internal/modules/cjs/helpers:108:19) at requireResolveNonCached (C:\Users\Victoria\AppData\Roaming\npm\node_modules\ts-node\dist\bin.js:321:16) at getProjectSearchDir (C:\Users\Victoria\AppData\Roaming\npm\node_modules\ts-node\dist\bin.js:291:40) at main (C:\Users\Victoria\AppData\Roaming\npm\node_modules\ts-node\dist\bin.js:193:27) at Object. (C:\Users\Victoria\AppData\Roaming\npm\node_modules\ts-node\dist\bin.js:351:5) at Module._compile (node:internal/modules/cjs/loader:1101:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) { code: 'MODULE_NOT_FOUND', requireStack: [ 'C:\Users\Victoria \Desktop\vicc\metaplex\js\packages\cli\src\imaginaryUncacheableRequireResolveScript' ] }

Then I tried

ts-node js/packages/cli/src/candy-machine-v1-cli.ts upload ./assets --env devnet --keypair ~/.config/solana/devnet-test.json

And this shows

[ERR] error: unknown command 'upload'

I really have no idea on how to fix this, would appreciate all the help.

Yilmaz
  • 35,338
  • 10
  • 157
  • 202
Victoriavv
  • 93
  • 1
  • 9
  • 2
    It seems you renamed the file from `candy-machine-cli.ts` to `candy-machine-v1-cli.ts`, at least your two examples use different files – Khez Jan 14 '22 at 05:26
  • When I looks into what’s under src, there appears to be a ‘candy-machine-v1-cli.ts’ and ‘candy-machine-v2-cli.ts’. So I randomly choose one and see if anything will change. And the result is another error shows up. – Victoriavv Jan 15 '22 at 00:31

3 Answers3

3

I encountered the same issue as well. The trick here is to implement and get candy-machine working by using candy-machine-v2-cli.ts.

Candy Machine v1 is deprecated and it is v2 that you should use to create your candy machine.

The steps remain the same and you could try running the below command (which can be found with explanation here):-

ts-node ~/metaplex/js/packages/cli/src/candy-machine-v2-cli.ts upload \
    -e devnet \
    -k ~/.config/solana/devnet.json \
    -cp config.json \
    -c example \
    ./assets

Besides all this, I would recommend you read the docs on Candy Machine v2. It has covered things comprehensively.

Tyler2P
  • 2,324
  • 26
  • 22
  • 31
jeremy
  • 59
  • 7
  • thanks i followed the docs and created a config.json under src and now it's saying "Error: ENOENT: no such file or directory, open 'config.json'". – Victoriavv Jan 15 '22 at 00:12
  • I was also wondering why other people could simply type "candy-machine-cli.ts" in the command without having the problems i'm having, we git clone the whole thing from metaplex so I suppose we should get the same result? – Victoriavv Jan 15 '22 at 00:16
  • 1
    Hey, so I had the same config.json error as well. I've opened up an issue in their github repo but am still waiting a reply. I do genuinely think that there is some breaking point somewhere. Check the issue at : https://github.com/metaplex-foundation/metaplex/issues/1553 – jeremy Jan 15 '22 at 19:25
  • My guess as to why other people could simply type in "candy-machine-cli.ts" and have everything work is prolly because they used metaplex's nft candy machine at a time when v1 was only available (and there was no need call things by version numbers). If you happen to look at the /js/packages/cli/src/ directory, it is clear that "candy-machine-cli.ts" is not available there at all anymore. – jeremy Jan 15 '22 at 19:30
  • Oh yea that makes sense, but both YouTube video I followed are made in 2021 oct and nov, metaplex probably updated the candy machine then – Victoriavv Jan 16 '22 at 04:29
0

first, create a config.json file in your root folder. follow https://docs.metaplex.com/candy-machine-v2/configuration

then run the command below in your terminal---

ts-node js/packages/cli/src/candy-machine-v2-cli.ts upload -e devnet --keypair -cp config.json -c example ./assets

get your keypair-path by using-- solana config get

this is work for me...

Rabbi H
  • 41
  • 2
0

That error happens because you installed candy machine in a different location than this: js/packages/cli/src/candy-machine-v1-cli.ts. I had the same issue. I cloned the project into ~/metaplex directory in Linux.

git clone https://github.com/metaplex-foundation/metaplex.git ~/metaplex

then inside ~/metaplex run this command to install metaplex:

yarn install --cwd js

check the version. candy-machine-v2-cli.ts is in ~/metaplex

ts-node ~/metaplex/js/packages/cli/src/candy-machine-v2-cli.ts --version

So when I run command to upload, I put the location of candy-machine-v2-cli.ts

ts-node ~/metaplex/js/packages/cli/src/candy-machine-v2-cli.ts upload -e devnet -k ~./config/solana/devnet.json -cp config.json ./assets 

Note

Since you are on Windows, ~/ this might not work. So write the correct path

Yilmaz
  • 35,338
  • 10
  • 157
  • 202