【问题标题】:Error: Unable to read configuration file newrelic.js错误:无法读取配置文件 newrelic.js
【发布时间】:2019-07-24 20:30:28
【问题描述】:

我收到此错误:

Error: Unable to read configuration file newrelic.js. 
A base configuration file can be copied from 536 and renamed to in the 
directory from which you will start your application.

项目是带有 SSR 的 Angular 7 SPA。

【问题讨论】:

    标签: node.js webpack newrelic angular-universal


    【解决方案1】:

    有两种解决方案: bj97301 在official new relic forums 上的第一个。

    1. 在我的 webpack 配置文件中,将 newrelic 设为外部:

      外部:['newrelic']

    2. 在我的 webpack 配置文件中,使用 commonjs 作为我的输出库目标:

      输出:{ libraryTarget: 'commonjs'}

    3. 更改 newrelic.js 以使用导出。而不是导出:

      原为:export const config = {

      现在:exports.config = {

    如果您想部署整个包以删除服务器,则此方法将不起作用,因为您排除了新的 relic 包。 要解决这个问题,您可以使用第二种方法。 作为一种解决方法,更改 newrelic.js 以覆盖环境变量而不是导出配置。

    例如

    process.env.NEW_RELIC_NO_CONFIG_FILE = 'true';
    process.env.NEW_RELIC_APP_NAME = 'YOUR APP NAME';
    process.env.NEW_RELIC_LICENSE_KEY = 'YOUR_KEY';
    process.env.NEW_RELIC_LOG_LEVEL = 'warn';
    process.env.NEW_RELIC_ALLOW_ALL_HEADERS = 'true';
    console.log('New relic has been configurated.');
    

    您可以删除导出的原始配置:

    'use strict';
    exports.config = {
      app_name: [],
      license_key: '',
      logging: {
        level: 'warning'
      },
      allow_all_headers: true
      }
    

    别忘了在你的 server.ts 上加上 require,只需添加:

    require('./newrelic');
    

    我希望它可以节省一些时间。

    【讨论】:

      猜你喜欢
      • 2017-04-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-20
      • 2023-04-06
      • 2016-07-09
      • 1970-01-01
      • 2019-01-08
      相关资源
      最近更新 更多