ApplicationInsights-node.js: Cannot find module 'diagnostic-channel'

I am trying to add application insights to my node/express app. I have applicationinsights v0.20.0 installed and now I am getting this error and my app will not run. I do see the ‘diagnostic-channel’ folder in that directory so I am not sure why it says it cannot locate it. On previous projects, I did not have this ‘diagnostic-channel’ when using app insights. Any thoughts?

Application has thrown an uncaught exception and is terminated:
Error: Cannot find module 'diagnostic-channel'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (D:\home\site\wwwroot\node_modules\applicationinsights\out\AutoCollection\CorrelationContextManager.js:4:28)
    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)
    at Function.Module._load (module.js:438:3)

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 25 (13 by maintainers)

Commits related to this issue

Most upvoted comments

Hi @OsvaldoRosado @AlexBulankou I just encountered this issue with Node v6.9.4, npm v3.10.10, and applicationinsights v1.0.1. My app is running locally, so it can’t be a permissions/deploy problem.

This is the error message:

./~/diagnostic-channel/dist/src/channel.js
Module not found: Can't resolve 'module' in 'C:\<path>\node_modules\diagnostic-channel\dist\src'

This is my npm node module structure:

+-- applicationinsights@1.0.1
| +-- diagnostic-channel@0.2.0
| +-- diagnostic-channel-publishers@0.2.1
| ` -- zone.js@0.7.6

The node_modules\diagnostic-channel\package.json file is readable, and node_modules\diagnostic-channel\dist\channel.js exists.

Any ideas?

UPDATE: Quickly figured out I was using wrong module, should have been using applicationinsights-js for client-side app insights. Making this note for anyone who stumbles across this issue. Thanks!

@MSLaguana the .dist folder seems to be fairly unreliably deployed given the history of this bug. What do you think of renaming it to no longer being a dot-folder?

We’ve encountered the same issue and it turned out that due to our build process, the .dist folder inside diagnostic-channel module was being omitted, that is because by default grunt-copy does not copy dot folders.