Browse Source

Добавлена отладка vs

Vadim 3 months ago
parent
commit
93c8961b31
5 changed files with 54 additions and 2 deletions
  1. 44 0
      .vscode/launch.json
  2. 6 0
      nodemon.debug.json
  3. 1 1
      nodemon.json
  4. 2 0
      package.json
  5. 1 1
      tsconfig.json

+ 44 - 0
.vscode/launch.json

@@ -0,0 +1,44 @@
+{
+  "version": "0.2.0",
+  "configurations": [
+    {
+      "type": "node",
+      "request": "attach",
+      "name": "Nodemon Attach (tsx)",
+      // "processId": "${command:PickProcess}", // Позволяет выбрать процесс, но мы будем использовать порт
+      "port": 9229, // Должен совпадать с портом в nodemon.debug.json
+      "address": "localhost", // Или 0.0.0.0 если есть проблемы с подключением
+      "restart": true, // Очень важно! VS Code будет пытаться переподключиться после перезапуска nodemon
+      "sourceMaps": true, // Включаем поддержку source maps для TypeScript
+      "localRoot": "${workspaceFolder}",
+      "remoteRoot": "${workspaceFolder}", // Если отладка идет на той же машине
+      "skipFiles": [
+        "<node_internals>/**", // Пропускать внутренние файлы Node.js
+        "node_modules/**" // Пропускать файлы из node_modules
+      ],
+      "outFiles": [
+        // Помогает VS Code найти скомпилированные JS файлы, если source maps не абсолютны
+        "${workspaceFolder}/build/**/*.js" // Если бы вы компилировали в /build
+        // Для tsx это обычно не так критично, так как он работает "на лету"
+      ],
+      "protocol": "inspector" // или "auto"
+    },
+    {
+      "type": "node",
+      "request": "launch",
+      "name": "Launch Program (tsx)",
+      "runtimeExecutable": "npx", // Используем npx для запуска tsx
+      "runtimeArgs": [
+        "tsx",
+        "./src/main.ts" // Ваш главный файл
+      ],
+      "args": [], // Аргументы для вашего приложения, если они есть
+      "cwd": "${workspaceFolder}",
+      "console": "integratedTerminal", // Куда выводить console.log и т.д.
+      "internalConsoleOptions": "neverOpen",
+      "envFile": "${workspaceFolder}/.dev.env", // Загрузка переменных окружения
+      "skipFiles": ["<node_internals>/**", "node_modules/**"],
+      "sourceMaps": true
+    }
+  ]
+}

+ 6 - 0
nodemon.debug.json

@@ -0,0 +1,6 @@
+{
+  "watch": ["src", ".env", ".dev.env"],
+  "ext": ".ts, .js",
+  "ignore": [],
+  "exec": "npx tsx --inspect-brk=0.0.0.0:9229 ./src/main.ts"
+}

+ 1 - 1
nodemon.json

@@ -2,5 +2,5 @@
   "watch": ["src", ".env", ".dev.env"],
   "ext": ".ts, .js",
   "ignore": [],
-  "exec": "npx tsx ./src/main.ts && npx eslint ./src"
+  "exec": "npx eslint ./src && npx tsx ./src/main.ts"
 }

+ 2 - 0
package.json

@@ -21,6 +21,7 @@
   },
   "scripts": {
     "dev": "npx nodemon",
+    "dev:debug": "npx nodemon --config nodemon.debug.json",
     "build": "rimraf ./build && npx tsc",
     "lint": "npx eslint ./src"
   },
@@ -60,6 +61,7 @@
     "@types/validator": "^13.15.1",
     "@typescript-eslint/eslint-plugin": "^6.21.0",
     "@typescript-eslint/parser": "^6.21.0",
+"cross-env": "^7.0.3",
     "eslint": "^8.57.1",
     "husky": "^8.0.3",
     "nodemon": "^3.1.9",

+ 1 - 1
tsconfig.json

@@ -70,7 +70,7 @@
     // "downlevelIteration": true,                       /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
     // "sourceRoot": "",                                 /* Specify the root path for debuggers to find the reference source code. */
     // "mapRoot": "",                                    /* Specify the location where debugger should locate map files instead of generated locations. */
-    // "inlineSources": true,                            /* Include source code in the sourcemaps inside the emitted JavaScript. */
+    "inlineSources": true /* Include source code in the sourcemaps inside the emitted JavaScript. */,
     // "emitBOM": true,                                  /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
     // "newLine": "crlf",                                /* Set the newline character for emitting files. */
     // "stripInternal": true,                            /* Disable emitting declarations that have '@internal' in their JSDoc comments. */