I'm integrating newrelic on nodejs app, made with angular universal. I am using webpack for bundling
first line in main.server.aot.ts
const newrelic = require('newrelic');
and have added newrelic.js in root directory as well.
running build ejects following error :-
ERROR in ./node_modules/@newrelic/native-metrics/lib/pre-build.js Module not found: Error: Can't resolve '../package' in 'D:\repos\ib-mobile\node_modules\@newrelic\native-metrics\lib' @ ./node_modules/@newrelic/native-metrics/lib/pre-build.js 40:12-33 @ ./node_modules/@newrelic/native-metrics/index.js @ ./node_modules/newrelic/lib/sampler.js @ ./node_modules/newrelic/lib/agent.js @ ./node_modules/newrelic/index.js @ ./src/main.server.aot.ts ERROR in ./node_modules/node-gyp/lib/node-gyp.js Module not found: Error: Can't resolve '../package' in 'D:\repos\ib-mobile\node_modules\node-gyp\lib' @ ./node_modules/node-gyp/lib/node-gyp.js 67:16-37 @ ./node_modules/@newrelic/native-metrics/lib/pre-build.js @ ./node_modules/@newrelic/native-metrics/index.js @ ./node_modules/newrelic/lib/sampler.js @ ./node_modules/newrelic/lib/agent.js @ ./node_modules/newrelic/index.js @ ./src/main.server.aot.ts ERROR in ./node_modules/newrelic/index.js Module not found: Error: Can't resolve './package' in 'D:\repos\ib-mobile\node_modules\newrelic' @ ./node_modules/newrelic/index.js 13:19-39 @ ./src/main.server.aot.ts
and if I add newrelic as externals in webpack config
module.exports = {
entry: root('./src/main.server.aot.ts'),
output: {
path: root('dist_server'),
filename: 'server.js'
},
target: 'node',
externals: {
newrelic: true
}
};
then I get another error as
/home/ubuntu/ib-mobile/dist_server/server.js:79752
module.exports = newrelic; ^ ReferenceError: newrelic is not defined at Object.<anonymous> (/home/ubuntu/ib-mobile/dist_server/server.js:79752:18) at __webpack_require__ (/home/ubuntu/ib-mobile/dist_server/server.js:26:30) at Object.module.exports (/home/ubuntu/ib-mobile/dist_server/server.js:79667:16) at __webpack_require__ (/home/ubuntu/ib-mobile/dist_server/server.js:26:30) at /home/ubuntu/ib-mobile/dist_server/server.js:91:18 at Object.<anonymous> (/home/ubuntu/ib-mobile/dist_server/server.js:94:10) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12)
Angular Version (ng -v)
Angular CLI: 1.6.3
Node: 6.11.0
OS: win32 x64
Angular: 4.4.6
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router
... tsc-wrapped
@angular/cli: 1.6.3
@angular-devkit/build-optimizer: 0.0.36
@angular-devkit/core: 0.0.22
@angular-devkit/schematics: 0.0.42
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.3
@schematics/angular: 0.1.11
@schematics/schematics: 0.0.11
typescript: 2.3.4
webpack: 3.10.0
const newrelic = require('newrelic');
– Identity