• EnglishEspañol日本語한국어Português
  • ログイン今すぐ開始

この機械翻訳は、参考として提供されています。

In the event of any inconsistency between the English version and the translated version, the English versionwill take priority. Please visit this page for more information.

問題を作成する

ソース マップのサポートを有効にする

TypeScript や Babel で記述されたアプリケーションなど、トランスパイルされたアプリケーションは、通常、ソース ファイルではなく、ビルドされたファイル内のファイル、行、および関数を指すエラー スタック トレースを表示します。

Node.js でソース マッピングを有効にすると、ソース コード内の行と関数を指す、より意味のあるエラー トレースが得られます。

ソース マッピングを有効にする方法

アプリケーションを起動するnodeコマンドで Node のソース マップ サポートを有効にできます。

bash
$
node --enable-source-maps -r newrelic ./dist/server.js

ソース マップのサポートなしでアプリケーションを実行すると、次のようなエラー スタック トレースが表示される場合があります。

bash
Error: Failed to get all entries in model
at /dist/models/entries.js:41:23
... (multiple functions in New Relic Node agent js files)
at /dist/models/entries.js:39:35
at Generator.next (<anonymous>)

ヒント

トレースは/distのビルド ファイルを参照することに注意してください。

ソース マップ サポートが有効になっている同じアプリケーションは、代わりにソース コード ファイルを参照します。

bash
Error: Failed to get all entries in model
at <anonymous> (/src/models/entries.ts:28:13)
... (multiple functions in New Relic Node agent js files)
at <anonymous> (/src/models/entries.ts:26:19)
at Generator.next (<anonymous>)

このスタック トレースは、ソース ファイル内の特定の関数と行番号を指しているため、エラーをより簡単に見つけることができます。

この動作は、ソース マップのサンプル アプリケーションを実行することで確認できます。これにより、ソース マップを有効にした場合と無効にした場合のエラー トレースを簡単に比較できます。

Copyright © 2024 New Relic株式会社。

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.