【问题标题】:elastic-apm-node with Webpack, Typescript & ES6 not working?带有 Webpack、Typescript 和 ES6 的 elastic-apm-node 不起作用?
【发布时间】:2019-11-02 01:05:24
【问题描述】:

我正在使用带有 webpack 和 babel 的 TypeScript 设置,并在尝试包含 elastic-apm-node 时收到以下错误。我在环境变量中有设置。

import * as apm from 'elastic-apm-node/start'
apm.flush()

错误:

WARNING in node_modules/elastic-apm-node/lib/agent.js 152:16-59
Critical dependency: the request of a dependency is an expression
 @ node_modules/elastic-apm-node/index.js

WARNING in node_modules/elastic-apm-node/lib/config.js 25:19-36
Critical dependency: the request of a dependency is an expression
 @ node_modules/elastic-apm-node/lib/agent.js

WARNING in node_modules/elastic-apm-node/lib/instrumentation/index.js 169:16-30
Critical dependency: the request of a dependency is an expression
 @ node_modules/elastic-apm-node/lib/agent.js

ERROR in node_modules/elastic-apm-node/lib/agent.js
Module not found: Error: Can't resolve '../package' in 'node_modules/elastic-apm-node/lib'
 @ node_modules/elastic-apm-node/lib/agent.js 25:14-35

ERROR in node_modules/elastic-apm-node/lib/config.js
Module not found: Error: Can't resolve '../package' in 'node_modules/elastic-apm-node/lib'
 @ node_modules/elastic-apm-node/lib/config.js 12:14-35

ERROR in node_modules/elastic-apm-http-client/index.js
Module not found: Error: Can't resolve './package' in 'node_modules/elastic-apm-http-client'
 @ node_modules/elastic-apm-http-client/index.js 15:12-32

ERROR in node_modules/spdx-expression-parse/scan.js
Module not found: Error: Can't resolve 'spdx-exceptions' in 'node_modules/spdx-expression-parse'
 @ node_modules/spdx-expression-parse/scan.js 6:17-43

ERROR in node_modules/spdx-correct/index.js
Module not found: Error: Can't resolve 'spdx-license-ids' in 'node_modules/spdx-correct'
 @ node_modules/spdx-correct/index.js 17:21-48

ERROR in node_modules/spdx-expression-parse/scan.js
Module not found: Error: Can't resolve 'spdx-license-ids' in 'node_modules/spdx-expression-parse'
W20190619-11:37:30.394(2)? (STDERR)      @ node_modules/spdx-expression-parse/scan.js 4:10-37

ERROR in node_modules/spdx-expression-parse/scan.js
Module not found: Error: Can't resolve 'spdx-license-ids/deprecated' in 'node_modules/spdx-expression-parse'
 @ node_modules/spdx-expression-parse/scan.js 5:10-48

知道如何防止这种情况发生吗?当仅使用带有 Meteor 的 TypeScript 时,我没有收到错误,所以我认为它连接到 Babel / Webpack。

【问题讨论】:

    标签: node.js typescript webpack elastic-stack


    【解决方案1】:

    错误答案 - 我在 webpack.config.js 中有自定义 resole.extensions:

    resolve: {
      extensions: ['.ts', '.tsx', '.js', '.jsx']
    },
    

    那是缺少默认的.json

    resolve: {
      extensions: ['.ts', '.tsx', '.js', '.jsx', '.json']
    },
    

    现在只剩下警告:

    WARNING in node_modules/elastic-apm-node/lib/agent.js 152:16-59
    Critical dependency: the request of a dependency is an expression
     @ node_modules/elastic-apm-node/index.js
    
    WARNING in node_modules/elastic-apm-node/lib/config.js 25:19-36
    Critical dependency: the request of a dependency is an expression
     @ node_modules/elastic-apm-node/lib/agent.js
    
    WARNING in node_modules/elastic-apm-node/lib/instrumentation/index.js 169:16-30
    Critical dependency: the request of a dependency is an expression
     @ node_modules/elastic-apm-node/lib/agent.js
    

    我将它们发送给开发者:https://github.com/elastic/apm-agent-nodejs/issues/1154

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-03-13
      • 2018-07-04
      • 2017-09-02
      • 2018-01-09
      • 1970-01-01
      • 1970-01-01
      • 2016-02-28
      • 2018-01-30
      相关资源
      最近更新 更多