Pythagora-io/pythagora

Error: Cannot find module unit.js

jcubic opened this issue · 10 comments

jcubic commented

Got this error:

$ npx pythagora --unit-tests --path index.js 
Need to install the following packages:
  pythagora@0.0.63
Ok to proceed? (y) y
Generating unit tests...
node:internal/modules/cjs/loader:1078
  throw err;
  ^

Error: Cannot find module '/home/kuba/projects/jcubic/wayne/repo/node_modules/pythagora/src/scripts/unit.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
    at Module._load (node:internal/modules/cjs/loader:920:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v18.16.0
Bash script exited with code 0

when running on my Wayne library

hey @jcubic thanks so much for trying it out! I just tried it on my laptop and it worked for me. Here is what i did:

  • git clone https://github.com/jcubic/wayne.git
  • cd wayne
  • npm i pythagora
  • npx pythagora --config --pythagora-api-key <PYTHAGORA_API_KEY> //you can change --pythagora-api-key with --openai-api-key if you have one and if it has access to gpt4
  • npx pythagora --unit-tests --path index.js


I see that you have in path ".../wayne/repo/node_modules/..." what is this "repo" folder? pythagora should be installed in root of project. Besides that can you give me more info on your setup please? What is OS that you are using, what is node and npm versions you have?

jcubic commented

It's git repository, I often have different testing files that should not be in the repo. The Readme doest show that you need some kind of API KEY.

I use latest Node on Fedora.

Ah ok, makes sense. Instead of installing pythagora inside "repo" folder, can you try uninstall it there and install it in root of project? I wonder if that will make any difference.

Regarding API KEY, you are right, it is not mentioned in "Quickstart" section but it is written bellow in "Config" section. But thanks, I will write the feedback down. We should change that to make it more clear.

If you run command without setting up key you should see this:
Screenshot 2023-06-12 at 15 31 53

jcubic commented

But Repo is the root of the project. It's where .git, package.json, and node_module directories are located.

jcubic commented

So your quick start is not actually quick start because it doesn't work you need to do extra steps to make the app works. Plesea update README to show what is exactly needed to run.

But Repo is the root of the project. It's where .git, package.json, and node_module directories are located.

ooooh I get it! Sorry about that, I misunderstood it. Once i cloned your repo that you linked it was in folder "wayne" so I just assumed wrongly that you have same setup and folder would be named same. Well, in that case it should all work. It is trying to start correct script which should be in './node_modules/pythagora/src/scripts/unit.js'. Can you please check if you have that file?

jcubic commented

If I installed the package first (which should work without like any other npm package) it throw this error:

$ npx pythagora --unit-tests --path index.js 
Generating unit tests...
Mode not provided. Defaulting to "capture".
Running "--unit-tests --path index.js" using Pythagora in "CAPTURE" mode.
node:internal/modules/cjs/loader:1042
  throw err;
  ^

Error: Cannot find module './CmdPrint'
Require stack:
- /home/kuba/projects/jcubic/wayne/repo/node_modules/pythagora/src/utils/Spinner.js
- /home/kuba/projects/jcubic/wayne/repo/node_modules/pythagora/src/helpers/cmdGUI.js
- /home/kuba/projects/jcubic/wayne/repo/node_modules/pythagora/src/helpers/unitTests.js
- /home/kuba/projects/jcubic/wayne/repo/node_modules/pythagora/src/scripts/unit.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1039:15)
    at Module._load (node:internal/modules/cjs/loader:885:27)
    at Module.require (node:internal/modules/cjs/loader:1105:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/home/kuba/projects/jcubic/wayne/repo/node_modules/pythagora/src/utils/Spinner.js:2:31)
    at Module._compile (node:internal/modules/cjs/loader:1218:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
    at Module.load (node:internal/modules/cjs/loader:1081:32)
    at Module._load (node:internal/modules/cjs/loader:922:12)
    at Module.require (node:internal/modules/cjs/loader:1105:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/kuba/projects/jcubic/wayne/repo/node_modules/pythagora/src/utils/Spinner.js',
    '/home/kuba/projects/jcubic/wayne/repo/node_modules/pythagora/src/helpers/cmdGUI.js',
    '/home/kuba/projects/jcubic/wayne/repo/node_modules/pythagora/src/helpers/unitTests.js',
    '/home/kuba/projects/jcubic/wayne/repo/node_modules/pythagora/src/scripts/unit.js'
  ]
}

Node.js v18.13.0
Bash script exited with code 0

hey @jcubic , we have made some fixes and hopefully now everything will work. Can you please install newest version of pythagora which is 0.0.64 and try it out. Let me know if you get stuck somewhere. Thank you! 🙏

jcubic commented

Now I have an error about the API key:

Mode not provided. Defaulting to "capture".
Running "--unit-tests --path index.js" using Pythagora in "CAPTURE" mode.
No API key found!
Please run:
npx pythagora --config --pythagora-api-key <YOUR_PYTHAGORA_API_KEY>
or
npx pythagora --config --openai-api-key <YOUR_OPENAI_API_KEY>
You can get Pythagora API key here: https://mailchi.mp/f4f4d7270a7a/api-waitlist
Bash script exited with code 0

Which I think means that it works.

Yes, this works now. You just have to set API key and you are good to go. Thank you so much for helping me debug this!