antonA
tRPC5mo ago
2 replies
anton

Error: Could not find source file for path

When I start nx serve server, I get an error:
Error: Could not find source file for path directory\apps\server\src\app\app.module.ts,
make sure "sourceMap" is enabled in your tsconfig.

apps/server/tsconfig.app.json
{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "outDir": "../../dist/apps/server",
    "module": "commonjs",
    "types": ["node"],
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "target": "es2021",
    "sourceMap": true
  },
  "include": ["src/**/*.ts"]
}


apps/server/webpack.config.js
const { NxAppWebpackPlugin } = require('@nx/webpack/app-plugin');

module.exports = {
  output: {
    path: join(__dirname, '../../dist/apps/server'),
  },
  plugins: [
    new NxAppWebpackPlugin({
      target: 'node',
      compiler: 'tsc',
      main: './src/main.ts',
      tsConfig: './tsconfig.app.json',
      assets: [],
      outputHashing: 'none',
      optimization: false,
      generatePackageJson: true,
      sourceMap: true
    }),
  ],
};


apps/server/project.json
{
  "targets": {
    "build": {
      "executor": "nx:run-commands",
      "options": {
        "command": "webpack --config apps/server/webpack.config.js"
      }
    },
    "serve": {
      "executor": "nx:run-commands", 
      "options": {
        "command": "ts-node-dev --respawn --prefer-ts-exts --project apps/server/tsconfig.app.json --require tsconfig-paths/register apps/server/src/main.ts"
      }
    }
  }
}


tsconfig.base.json (root)
{
  "compilerOptions": {
    "sourceMap": true,
    // ... остальные опции
  }
}


What I've already tried

Added “sourceMap: true to all tsconfig files
Added sourceMap: true to NxAppWebpackPlugin
Cleared the cache via nx reset

The error occurs only with nx serve server; nx build server works but does not generate schemas.
Was this page helpful?