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

Cannot find module upon startup v3.0.0 #167

Open
prenetic opened this issue Apr 1, 2023 · 3 comments
Open

Cannot find module upon startup v3.0.0 #167

prenetic opened this issue Apr 1, 2023 · 3 comments

Comments

@prenetic
Copy link

prenetic commented Apr 1, 2023

Windows Server 2022 21H2
Node.js 18.15.0
Yarn 1.22.19
discord-soundbot 3.0.0

With my current installation, as well as a fresh copy of the 3.0.0 release .zip, I receive the error Cannot find module '~/util/Container' upon startup. Below are complete logs from yarn install through yarn start. The file dist/src/util/Container.js exists relative to the package's root path.

C:\Program Files (User)\discord-soundbot-3.0.0>yarn install
yarn install v1.22.19
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
[4/5] Linking dependencies...
[5/5] Building fresh packages...
Done in 42.57s.

C:\Program Files (User)\discord-soundbot-3.0.0>yarn start
yarn run v1.22.19
$ npm run build && npm run serve

> discord-soundbot@main build
> tsc -p tsconfig.json && tsconfig-replace-paths -p tsconfig.json

Replaced 0 paths in 0 files

> discord-soundbot@main serve
> node dist/bin/soundbot.js

node:internal/modules/cjs/loader:1078
  throw err;
  ^

Error: Cannot find module '~/util/Container'
Require stack:
- C:\Program Files (User)\discord-soundbot-3.0.0\dist\bin\soundbot.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
    at Module._load (node:internal/modules/cjs/loader:920:27)
    at Module.require (node:internal/modules/cjs/loader:1141:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at Object.<anonymous> (C:\Program Files (User)\discord-soundbot-3.0.0\dist\bin\soundbot.js:7:37)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Module._load (node:internal/modules/cjs/loader:958:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\Program Files (User)\\discord-soundbot-3.0.0\\dist\\bin\\soundbot.js'
  ]
}

Node.js v18.15.0
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

C:\Program Files (User)\discord-soundbot-3.0.0>
@prenetic
Copy link
Author

prenetic commented Jul 31, 2023

Still an issue with the latest commit (bdbe17f).

Contents of C:\Program Files (User)\discord-soundbot\src\util:

2023-03-31  20:59    <DIR>          .
2023-03-31  20:59    <DIR>          ..
2023-03-31  20:59             2,908 Container.ts
2023-03-31  20:59    <DIR>          db
2023-03-31  20:59             1,241 Errors.ts
2023-03-31  20:59               687 getSecondsFromTime.ts
2023-03-31  20:59    <DIR>          i18n
2023-03-31  20:59               899 SoundUtil.ts
2023-03-31  20:59    <DIR>          __mocks__
2023-03-31  20:58    <DIR>          __test__

Contents of C:\Program Files (User)\discord-soundbot\dist\src\util:

2023-03-31  22:11    <DIR>          .
2023-03-31  22:11    <DIR>          ..
2023-07-30  17:00             3,269 Container.js
2023-03-31  22:11    <DIR>          db
2023-03-31  22:11             2,192 Errors.js
2023-03-31  22:11               759 getSecondsFromTime.js
2023-03-31  22:11    <DIR>          i18n
2023-07-30  17:00             1,505 SoundUtil.js

@markokajzer
Copy link
Owner

hmm... seems to maybe be a windows related issue? this should not say 0 paths in 0 files

discord-soundbot@main build
tsc -p tsconfig.json && tsconfig-replace-paths -p tsconfig.json

Replaced 0 paths in 0 files

Nowadays, there are some other tools to do exactly what i was trying to do with this hack. maybe i can see to replace it and fix this issue for all platforms 👍

@markokajzer
Copy link
Owner

markokajzer commented Sep 9, 2024

I... there are so many issues with all this path stuff and module resolution in typescript<>node that i either dont understand or dont want to understand tbh. there's some real insane shit like this as well which i'm not gonna do

i only ever see things like this in the javascript ecosystem lmao

compilerOptions.paths should just work... but it doesn't and they dont want it to lmao

anyway, i replaced tsconfig-replace-paths with module-alias which should hopefully work, and at the very least save me a headache.

i'm tinkering around with a whole bunch of stuff, so i'm not even sure if it will work right now. but i'll verify over the next few days. feel free to also give it a spin 🤙

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

No branches or pull requests

2 participants