elastic-apm-node with Webpack, Typescript & ES6 not working?

Viewed 1530

I am using a TypeScript setup with webpack and babel and get the following error when trying to include elastic-apm-node. I have the settings in environment variables.

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

Errors:

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

Any idea how I can prevent this? When using just TypeScript with Meteor I don't get the errors, so I think it is connected to Babel / Webpack.

1 Answers

Answer to the Errors - I have custom resole.extensions in the webpack.config.js:

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

That was missing the default .json:

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

Now only the warnings are left:

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

I addressed them to the developer: https://github.com/elastic/apm-agent-nodejs/issues/1154

Related