Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Cannot find module - Windows OS #896

Closed
directcuteo opened this issue May 8, 2023 · 4 comments · Fixed by o1-labs/o1js-bindings#19
Closed

Error: Cannot find module - Windows OS #896

directcuteo opened this issue May 8, 2023 · 4 comments · Fixed by o1-labs/o1js-bindings#19

Comments

@directcuteo
Copy link

I am trying to run a simple example from the HelloWorld tutorial but there is an error when I try to build the file:

npm run build
node build/src/main.js

D:\mina\hello-world-zk-app\node_modules\snarkyjs\dist\node\_node_bindings\snarky_js_node.bc.cjs:7427
         throw err;
         ^
Error: Cannot find module 'D:\D:\mina\hello-world-zk-app\node_modules\snarkyjs\dist\node\snarkyjs-bindings\js\node\node-backend.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1082:15)
    at Module._load (node:internal/modules/cjs/loader:928:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
    at MessagePort.<anonymous> (node:internal/main/worker_thread:185:26)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:762:20)
    at exports.emitMessage (node:internal/per_context/messageport:23:28)
Emitted 'error' event on Worker instance at:
    at [kOnErrorMessage] (node:internal/worker:323:10)
    at [kOnMessage] (node:internal/worker:334:37)
    at MessagePort.<anonymous> (node:internal/worker:229:57)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:762:20)
    at exports.emitMessage (node:internal/per_context/messageport:23:28) {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

it is pretty clear what the error is: there is double "D" -> D:\D:\mina\hello-world-zk-app.......

My setup:

Windows 11
node v20.1.0
tsc 4.9.3
npm 8.4.1
@mitschabaude
Copy link
Member

Hi @directcuteo, thanks for the report! I can't reproduce the bug, but I'm on Linux. I wonder if it's a bug with node 20 on windows.

  • Do you experience the same on node 19?
  • Can you share the code of a minimal main.ts which reproduces the problem?

@directcuteo
Copy link
Author

Yes, I installed node v19 and I encounter the same error.

This is the entire code (I've put everything in one file). tsc command runs fine

import { AccountUpdate, Field, isReady, method, Mina, PrivateKey, shutdown, SmartContract, state, State } from 'snarkyjs';

export class Square extends SmartContract {
  @state(Field) num = State<Field>();

  init() {
    super.init();
    this.num.set(Field(3));
  }

  @method update(square: Field) {
    const currentState = this.num.get();
    this.num.assertEquals(currentState);
    square.assertEquals(currentState.mul(currentState));
    this.num.set(square);
  }
}

await isReady;
console.log('SnarkyJS loaded');
const useProof = false;
const Local = Mina.LocalBlockchain({ proofsEnabled: useProof });
Mina.setActiveInstance(Local);
const { privateKey: deployerKey, publicKey: deployerAccount } = Local.testAccounts[0];
const { privateKey: senderKey, publicKey: senderAccount } = Local.testAccounts[1];

const zkAppPrivateKey = PrivateKey.random();
const zkAppAddress = zkAppPrivateKey.toPublicKey();

const zkAppInstance = new Square(zkAppAddress);
const deployTxn = await Mina.transaction(deployerAccount, () => {
  AccountUpdate.fundNewAccount(deployerAccount);
  zkAppInstance.deploy();
});
await deployTxn.sign([deployerKey, zkAppPrivateKey]).send();


// get the initial state of Square after deployment
const num0 = zkAppInstance.num.get();
console.log('state after init:', num0.toString());

// ----------------------------------------------------
const txn1 = await Mina.transaction(senderAccount, () => {
  zkAppInstance.update(Field(9));
});
await txn1.prove();
await txn1.sign([senderKey]).send();

const num1 = zkAppInstance.num.get();
console.log('state after txn1:', num1.toString());
// ----------------------------------------------------

console.log('Shutting down');
await shutdown();

The error is gone if I comment the line await txn1.prove();
Thank you for helping!

@directcuteo
Copy link
Author

@mitschabaude I hope there is enough information so you can investigate this issue. I am waiting for your response. Thank you!

@mitschabaude
Copy link
Member

Thanks @directcuteo, I'll find someone on the team with Windows so we can investigate this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants