'Candy Machine v2 - error: required option '-k, --keypair <path>' not specified

I have done numerous tutorials, and followed everything step by step but I keep getting stuck at this one step, running the following command:

npx ts-node ~/solana-nft/metaplex/js/packages/cli/src/candy-machine-v2-cli.ts upload \ 
-e devnet \
-k keypair.json \ 
-cp config.json \ 
./assets
I have done this in multiple variations but I keep getting the error:
error: required option '-k, --keypair ' not specified

Help?! Driving me nuts

Yarn version 1.22.18 Node version v14.17.0 solana-cli 1.9.13 ts-node version v10.7.0

I tried running

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

and I always get the failure "error: required option '-k, --keypair <path> not specified'

I have tried multiple variations according to several tutorials and every time I get the same error.



Solution 1:[1]

This might be just be the way that it was copy-pasted, but the command has one additional space at the end of a few lines, making the escaped newline \ fail. So instead of:

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

you need to do

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

Solution 2:[2]

I think path to keypair is not correct. You create keypair:

solana-keygen new --outfile ~/.config/solana/devnet.json

then set this as default:

 solana config set --keypair ~/.config/solana/devnet.json

then you run upload command specifying ~/.config/solana/devnet.json as -k:

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jon C
Solution 2 Yilmaz