0

Мой ts.config:

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "outDir": "gen",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false,
    "lib": ["dom", "es5", "es6", "es2015.promise", "es2015.iterable", "es2015.collection", "es2015.reflect", "es2015.proxy"],
    "moduleResolution": "node",
    "typeRoots" : ["node_modules/@types"],
    "noUnusedLocals": false,
    "exclude": [
      "node_modules"
    ]
  }
}

Когда в консоли смотрю лог с ошибками стектрейс содержит ссылки на js файлы а не ts:

Error: ENOENT: no such file or directory, stat 'E:\test\gen\app\www\img\favicon.png'
    at Error (native)
    at Object.fs.statSync (fs.js:1000:11)
    at resolveSync (E:\test\node_modules\serve-favicon\index.js:172:17)
    at favicon (E:\test\node_modules\serve-favicon\index.js:61:12)
    at Object.<anonymous> (E:\test\gen\app\App.js:42:9)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)

Process finished with exit code 1

Непонятно почему так, при этом бряки в дебагере работают в ts-файлах. Подскажите что можно сделать чтоб ссылки в логе были на ts-файлы?

1 ответ 1

0

Попробуйте пакет source-map-support:

This module provides source map support for stack traces in node via the V8 stack trace API. It uses the source-map module to replace the paths and line numbers of source-mapped files with their original paths and line numbers. The output mimics node's stack trace format with the goal of making every compile-to-JS language more of a first-class citizen.

Достаточно установить пакет:

npm install --save source-map-support

Затем импортировать модуль:

require('source-map-support').install();

// ES6 import
import 'source-map-support/register';
1
  • В итоге написал свой плагин для gulp
    – sanu
    21 сен 2017 в 13:41

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.