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

npx repomix kabooms with "Cannot find module ... cliRun.js" #197

Open
yarikoptic opened this issue Dec 9, 2024 · 5 comments
Open

npx repomix kabooms with "Cannot find module ... cliRun.js" #197

yarikoptic opened this issue Dec 9, 2024 · 5 comments
Labels
question Further information is requested

Comments

@yarikoptic
Copy link

Might be a user error and RTFM (not a JS fella here) but tried to follow README.md stating:

You can try Repomix instantly in your project directory without installation:

npx repomix

and got (tried two ways) while running within the fresh clone at v0.2.5-10-g05589f7 :

❯ npx repomix
Fatal Error: {
  name: 'Error',
  message: "Cannot find module '/home/yoh/proj/misc/repomix/lib/cli/cliRun.js' imported from /home/yoh/proj/misc/repomix/bin/repomix.cjs",
  stack: "Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/home/yoh/proj/misc/repomix/lib/cli/cliRun.js' imported from /home/yoh/proj/misc/repomix/bin/repomix.cjs\n" +
    '    at finalizeResolution (node:internal/modules/esm/resolve:265:11)\n' +
    '    at moduleResolve (node:internal/modules/esm/resolve:933:10)\n' +
    '    at defaultResolve (node:internal/modules/esm/resolve:1169:11)\n' +
    '    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:542:12)\n' +
    '    at ModuleLoader.resolve (node:internal/modules/esm/loader:510:25)\n' +
    '    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:239:38)\n' +
    '    at ModuleLoader.import (node:internal/modules/esm/loader:472:34)\n' +
    '    at defaultImportModuleDynamicallyForScript (node:internal/modules/esm/utils:227:31)\n' +
    '    at importModuleDynamicallyCallback (node:internal/modules/esm/utils:249:12)\n' +
    '    at /home/yoh/proj/misc/repomix/bin/repomix.cjs:42:21'
}

❯ find -iname cliRun.js

❯ find -iname cliRun.*
./src/cli/cliRun.ts
./tests/cli/cliRun.test.ts

❯ npx .
Fatal Error: {
  name: 'Error',
  message: "Cannot find module '/home/yoh/.npm/_npx/bc821935aa97a4d0/node_modules/repomix/lib/cli/cliRun.js' imported from /home/yoh/.npm/_npx/bc821935aa97a4d0/node_modules/repomix/bin/repomix.cjs",
  stack: "Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/home/yoh/.npm/_npx/bc821935aa97a4d0/node_modules/repomix/lib/cli/cliRun.js' imported from /home/yoh/.npm/_npx/bc821935aa97a4d0/node_modules/repomix/bin/repomix.cjs\n" +
    '    at finalizeResolution (node:internal/modules/esm/resolve:265:11)\n' +
    '    at moduleResolve (node:internal/modules/esm/resolve:933:10)\n' +
    '    at defaultResolve (node:internal/modules/esm/resolve:1169:11)\n' +
    '    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:542:12)\n' +
    '    at ModuleLoader.resolve (node:internal/modules/esm/loader:510:25)\n' +
    '    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:239:38)\n' +
    '    at ModuleLoader.import (node:internal/modules/esm/loader:472:34)\n' +
    '    at defaultImportModuleDynamicallyForScript (node:internal/modules/esm/utils:227:31)\n' +
    '    at importModuleDynamicallyCallback (node:internal/modules/esm/utils:249:12)\n' +
    '    at /home/yoh/.npm/_npx/bc821935aa97a4d0/node_modules/repomix/bin/repomix.cjs:42:21'
}

versions info

❯ npx --version
9.2.0

❯ which npx
/usr/bin/npx

❯ dlocate /usr/bin/npx
npm: /usr/bin/npx

❯ apt-cache policy  npm
npm:
  Installed: 9.2.0~ds1-3
  Candidate: 9.2.0~ds1-3
  Version table:
 *** 9.2.0~ds1-3 900
        600 https://deb.debian.org/debian sid/main amd64 Packages
        600 https://deb.debian.org/debian sid/main i386 Packages
        900 https://deb.debian.org/debian trixie/main amd64 Packages
        900 https://deb.debian.org/debian trixie/main i386 Packages
        100 /var/lib/dpkg/status
     9.2.0~ds1-1 100
        100 https://deb.debian.org/debian bookworm/main amd64 Packages
        100 https://deb.debian.org/debian bookworm/main i386 Packages
@yamadashy
Copy link
Owner

yamadashy commented Dec 9, 2024

Hi, @yarikoptic !

Thanks for reporting this issue and providing detailed information including version details and exact error messages!

I noticed you're trying to run npx repomix inside the cloned Repomix repository itself. This can cause confusion with module resolution.

If you just want to use Repomix to analyze a project:

cd /path/to/your/project  # your project you want to analyze
npx repomix               # this will download and run Repomix directly

No need to clone the repository - npx will handle everything for you! Let me know if you have any questions!

@yarikoptic
Copy link
Author

thank you! quick one then, how to "install" it from a local clone of the repository? I have tried npm install but it produced no repomix "executable".

@yamadashy
Copy link
Owner

@yarikoptic
Ah, if you want to develop/run Repomix from the local clone, here's the correct setup:

git clone https://github.com/yamadashy/repomix.git
cd repomix
npm install

Then you can run it:

  1. npm run cli-run # This compiles TypeScript to JavaScript and run

The reason npm install alone doesn't create an executable is that we need to build the TypeScript files first. Let me know if you need any clarification!

@yarikoptic
Copy link
Author

THANK YOU!
Hopefully the last question -- npm run cli-run does run it within this repository, but how to "install" it now, e.g. to get repomix runnable script which I could invoke from any other location? (might be worth adding that to README.md in some "installing from source" section)

@yamadashy
Copy link
Owner

@yamadashy
Ah yes! If you want to install and use your local build globally (so you can run repomix from any directory), you can use npm link:

git clone https://github.com/yamadashy/repomix.git
cd repomix
npm install
npm run build
npm link      # This creates a global symlink to your local build

After this, you can run repomix from any directory!

Regarding adding this to README.md - I'm actually unsure about the demand for building from source since most users would probably just use npx repomix. Let me think about the best way to document this. Thanks for the suggestion though!

@yamadashy yamadashy added the question Further information is requested label Dec 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants