question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Cannot read property 'agent' of undefined

See original GitHub issue

Description

after update to node 16 I got this error

TypeError: Cannot read property 'agent' of undefined
    at instrumentDatastore (/Users/minafawzy/Documents/TechModgroup/BDS-API/node_modules/newrelic/api.js:1221:23)
    at Object.<anonymous> (/Users/minafawzy/Documents/TechModgroup/BDS-API/index.ts:3:20)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Module._compile (/Users/minafawzy/Documents/TechModgroup/BDS-API/node_modules/source-map-support/source-map-support.js:568:25)
    at Module.m._compile (/private/var/folders/qy/g_lynwh536s_39w1_47zgwz40000gn/T/ts-node-dev-hook-5979901015148208.js:69:33)
    at Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at require.extensions.<computed> (/private/var/folders/qy/g_lynwh536s_39w1_47zgwz40000gn/T/ts-node-dev-hook-5979901015148208.js:71:20)
    at Object.nodeDevHook [as .ts] (/Users/minafawzy/Documents/TechModgroup/BDS-API/node_modules/ts-node-dev/lib/hook.js:63:13)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)

Expected Behavior

to be working NOTE: # ( Tell us what you expected to happen. )

Troubleshooting or NR Diag results

Steps to Reproduce

work in node 16 NOTE: # ( Please be as specific as possible. ) TIP: # ( Link a sample application that demonstrates the issue. )

Your Environment

  • ex: Browser name and version:
  • ex: Node version:
  • ex: Operating System and version:

Additional context

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
darius-simplexcommented, Dec 30, 2021

This is caused by the way Typescript handles * imports (you can check generated JS code). It will work if you change:

import * as newrelic from "newrelic";

to

import newrelic from "newrelic";
0reactions
minaairsupportcommented, Dec 31, 2021

seems that was the issue thanks I am closing the issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error after setup node.js agent: Cannot read property ' ...
newrelic agent: v1.29.0 Question: I setup the node.js agent in my ... TypeError: Cannot read property '__NR_original' of undefined at ...
Read more >
nodejs/node - Gitter
agent = new https.Agent(options); ^ TypeError: Cannot read property 'Agent' of undefined at Object.<anonymous> (/data/opt/app.js:17:26) at Module._compile ( ...
Read more >
Cannot read properties of undefined (reading 'name'); - ...
TypeError: Cannot read properties of undefined (reading 'name'); ; Sounds like name isnt on body.data. Try printing just body.data, to determine ...
Read more >
Resolving TypeError: Cannot Read Property of Undefined ...
The TypeError: Cannot read property of undefined is one of the most common type errors in JavaScript. It occurs when a property is...
Read more >
TypeError: Cannot read property "predictedValue" f...
TypeError : Cannot read property "predictedValue" from undefined. Joshua Garrison. Kilo Contributor. Options.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found