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

Not working - paths are not being replaced #276

Open
matomesc opened this issue Jan 30, 2025 · 0 comments
Open

Not working - paths are not being replaced #276

matomesc opened this issue Jan 30, 2025 · 0 comments

Comments

@matomesc
Copy link

I have the following config with paths:

{
  "compilerOptions": {
    "target": "ES2017",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "bundler",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "incremental": true,
    "paths": {
      "@/*": ["./src/*"]
    },
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true
  },
  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
  "exclude": ["node_modules"]
}

And I'm running the following node command: node --require tsconfig-paths/register --require reflect-metadata --enable-source-maps dist/web/src/server/web.js\"

But it's failing with the following error:

Error: Cannot find module '@/server/services/UsersService'
Require stack:
- /workspace/dist/web/src/server/workers/ExampleWorker.js
- /workspace/dist/web/src/server/web.js
    at Function.<anonymous> (node:internal/modules/cjs/loader:1249:15)
    at Function.Module._resolveFilename (/workspace/node_modules/tsconfig-paths/src/register.ts:115:36)
    at <anonymous> (/workspace/node_modules/next/src/server/require-hook.ts:51:34)
    at Function._load (node:internal/modules/cjs/loader:1075:27)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:219:24)
    at Module.<anonymous> (node:internal/modules/cjs/loader:1340:12)
    at Module.patchedRequire (/workspace/node_modules/require-in-the-middle/index.js:223:34)
    at Hook._require.Module.require (/workspace/node_modules/require-in-the-middle/index.js:171:27)
    at Module.mod.require (/workspace/node_modules/next/src/server/require-hook.ts:70:26) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/workspace/dist/web/src/server/workers/ExampleWorker.js',
    '/workspace/dist/web/src/server/web.js'
  ]
}

You can see that tsconfig-paths is part of the callstack but the path is not replaced. Any ideas on how to fix?

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

1 participant