我正在使用带有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
有什么办法可以防止这种情况吗?当仅将TypeScript与Meteor一起使用时,我没有收到错误,因此我认为它已连接到Babel / Webpack。
答案 0 :(得分:0)
错误的答案-我在MeasurementFormatter
中有自定义的resole.extensions:
string(from:)
缺少默认的import Foundation
let url = Bundle.main.url(forResource: "image", withExtension: "png")!
let data = try! Data(contentsOf: url)
let byteCount = data.count
print(byteCount) // prints: 2636725
let byteSize = Measurement(value: Double(byteCount), unit: UnitInformationStorage.bytes)
let convertedSize = byteSize.converted(to: .megabytes)
let formatter = MeasurementFormatter()
let displaySize = formatter.string(from: convertedSize)
print(displaySize) // prints: 2.637 MB
:
webpack.config.js
现在只剩下警告了:
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx']
},