zkapp-cli
zkapp-cli copied to clipboard
Deploy a smart contract within a folder
Describe the bug
I'm trying to deploy a smart contract within a folder. Folder structure:
- src -- guardians --- GuardianZkApp.ts
Command:
zk deploy
✔ Which deploy alias do you want to deploy to? · berkeley
✔ Build project
✔ Generate build.json
✔ Choose smart contract to deploy · GuardianZkApp
Your config.json was updated to always use this
smart contract when deploying to this deploy alias.
Error:
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '../build/src/GuardianZkApp.js' imported from /../.nvm/versions/node/v20.11.0/lib/node_modules/zkapp-cli/src/lib/deploy.js
at finalizeResolution (node:internal/modules/esm/resolve:264:11)
at moduleResolve (node:internal/modules/esm/resolve:917:10)
at defaultResolve (node:internal/modules/esm/resolve:1130:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:396:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:365:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:240:38)
at ModuleLoader.import (node:internal/modules/esm/loader:328:34)
at importModuleDynamically (node:internal/modules/esm/translators:158:35)
at importModuleDynamicallyCallback (node:internal/modules/esm/utils:207:14)
at deploy (file:///Users/iamdev/.nvm/versions/node/v20.11.0/lib/node_modules/zkapp-cli/src/lib/deploy.js:247:32)
at async Object.handler (file:///../.nvm/versions/node/v20.11.0/lib/node_modules/zkapp-cli/src/bin/index.js:127:21) {
code: 'ERR_MODULE_NOT_FOUND',
url: 'file:///../build/src/GuardianZkApp.js'
}
Steps to Reproduce
- Create a smart contract within a new folder.
- zk deploy
- choose the new smart contract
- Error occurred
System Info
Be sure to include the following system information when submitting a GitHub issue:
System:
OS: macOS 14.3.1
CPU: (8) arm64 Apple M2
Binaries:
Node: 20.11.0 - ~/.nvm/versions/node/v20.11.0/bin/node
Yarn: 1.22.21 - /opt/homebrew/bin/yarn
npm: 10.2.4 - ~/.nvm/versions/node/v20.11.0/bin/npm
npmPackages:
o1js: 0.16.2
npmGlobalPackages:
zkapp-cli: 0.17.2
Severity
serious, but I can work around it
Additional Information
No response
Build folder structure:
Thanks for bringing this up @iam-dev. We will take a look at this. Are you experiencing the same problem if all your contracts are directly in the src folder and not nested? Did you enter zk config before entering zk deploy?
No, this works fine under src folder
I can confirm this issue is still present on version 0.18.0. I also had to move the contract to the top level src folder to solve this issue.
The source of the issue seems to be the usage of basename which should probably be resolve in order to use absolute paths:
https://github.com/o1-labs/zkapp-cli/blob/1f2e2ddc8141ab1435931f519ee97bcf80749366/src/lib/deploy.js#L782
@iam-dev Could you confirm if this issue is still occurring? I tried to reproduce it but couldn't encounter the problem. As long as I include the zkApp name in config.json, it deploys successfully, even when located in a nested folder.