Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module 'diagnostic-channel' #256

Closed
c-visca opened this issue May 25, 2017 · 25 comments · Fixed by #303
Closed

Cannot find module 'diagnostic-channel' #256

c-visca opened this issue May 25, 2017 · 25 comments · Fixed by #303
Labels
Milestone

Comments

@c-visca
Copy link

c-visca commented May 25, 2017

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)

@OsvaldoRosado
Copy link
Member

Thanks for reporting this! What versions of Node and NPM are you using? Are you using any libraries that give you an alternative package loader?

@c-visca
Copy link
Author

c-visca commented May 25, 2017

I am using Node v6.10.1 and NPM v3.10.10.

@OsvaldoRosado
Copy link
Member

OsvaldoRosado commented May 25, 2017

Just to verify, you have applicationinsights in your project.json file and used npm install to download it, correct? The resulting node_modules folder structure looks like this as well?

node_modules
|_ applicationinsights
|_ diagnostic-channel
|_ diagnostic-channel-publishers
|_ semver
|_ zone.js

Thanks!

@c-visca
Copy link
Author

c-visca commented May 25, 2017

I installed it use the npm package manager gui in Visual Studio. It is listed in my package.json file. My node_modules structure:

applicationinsights
 - out
  -- AutoCollection
   --- diagnostic-channel
  -- Declarations
  -- Library
  -- TelemetryProcessors
applicationinsights-js
diagnostic-channel
diagnostic-channel-publishers
semver
zone.js

@MSLaguana
Copy link
Member

Can you please double check that there is a node_modules\diagnostic-channel\package.json file which is readable, and also a node_modules\diagnostic-channel\.dist\channel.js file?

@c-visca
Copy link
Author

c-visca commented May 25, 2017

Yes, I have both files.

@OsvaldoRosado
Copy link
Member

I'm noticing that your installation is in wwwroot. Do you get this error only when running via IIS (vs local command line)

@c-visca
Copy link
Author

c-visca commented May 25, 2017

Yes, I am getting the error when trying to access my development/test site. It will work locally.

@OsvaldoRosado
Copy link
Member

Thanks! It sounds like this might be a permissions or deployment problem. Can you verify that the diagnostic-channel folder on your server has permissions to be read by the user account that runs the service? It might also be worthwhile to check that the files are deployed correctly in the first place. If this is an Azure App Service you can quickly check this with the App Service Editor

image

@c-visca
Copy link
Author

c-visca commented May 30, 2017

I didn't see any issues there. My site is getting ready to go live very soon so I had to reinstall applicationinsights at a lower version. Thanks for your help!

@OsvaldoRosado
Copy link
Member

I've validated this is working on a clean VS2017 nodejs project, with applicationinsights installed using the VS NPM tooling, and published to an azure app service. Closing for now.

Please feel free to re-open if you run into this again!

@martincostello
Copy link
Contributor

I've just had the problem occur updating an AWS Lambda with the ApplicationInsights version changed from 0.19.0 to 0.21.0:

{
  "errorMessage": "Cannot find module 'diagnostic-channel'",
  "errorType": "Error",
  "stackTrace": [
    "Function.Module._load (module.js:276:25)",
    "Module.require (module.js:353:17)",
    "require (internal/module.js:12:17)",
    "Object.<anonymous> (/var/task/node_modules/applicationinsights/out/AutoCollection/CorrelationContextManager.js:4:28)",
    "Module._compile (module.js:409:26)",
    "Object.Module._extensions..js (module.js:416:10)",
    "Module.load (module.js:343:32)",
    "Function.Module._load (module.js:300:12)",
    "Module.require (module.js:353:17)",
    "require (internal/module.js:12:17)",
    "Object.<anonymous> (/var/task/node_modules/applicationinsights/out/applicationinsights.js:2:33)",
    "Module._compile (module.js:409:26)",
    "Object.Module._extensions..js (module.js:416:10)",
    "Module.load (module.js:343:32)",
    "Function.Module._load (module.js:300:12)"
  ]
}

@SergeyKanzhelev
Copy link

@martincostello this package is a new dependency of Application Insights SDK. Make sure your function is configured correctly and this package can be downloaded

@fpereira1
Copy link

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.

@OsvaldoRosado
Copy link
Member

@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?

@MSLaguana
Copy link
Member

I have no objection to that; @mike-kaufman / @jackhorton, we can fix this before our next release unless you feel strongly otherwise.

@mike-kaufman
Copy link

@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?

Hmmm... not following why the dot would impact things. Is this just a guess or do we understand why the dot in the name is interfering?

@OsvaldoRosado
Copy link
Member

OsvaldoRosado commented Aug 9, 2017

We have this specific example above in grunt omitting it by default, and the initial example was a case where it worked locally but the folder failed to deploy to the server. The second example, without further investigation, seems to be a lot like the first.

The suspicion is tooling designed to ignore dotfolders (usually always right, don't need to deploy .git, .vscode, etc)

@jackhorton
Copy link
Member

I think the change is fine. The dot doesn't add much for me, and we were already planning to do a new release soon to publishers to add some new modules.

@mike-kaufman
Copy link

We have this specific example above in grunt omitting it by default,

OK, sounds good.

@iernie
Copy link

iernie commented Aug 15, 2017

We had a similar issue where older nuget (3.x) versions would omit the .dist folder during pack. This was fixed for us by upgrading to a newer nuget version (4.x). Writing this here in case somebody else has the same issue we had.

@OsvaldoRosado
Copy link
Member

I'm not sure this is okay to close until we depend on a newer version of diagnostic-channel

@AlexBulankou AlexBulankou reopened this Aug 18, 2017
@AlexBulankou AlexBulankou added this to the Future milestone Aug 18, 2017
@AlexBulankou
Copy link
Contributor

Yes, didn't intend to close.

@AlexBulankou AlexBulankou added this to the 0.21.0 milestone Aug 18, 2017
@AlexBulankou AlexBulankou modified the milestones: Future, 0.22.0, 0.21.0 Aug 18, 2017
@AlexBulankou AlexBulankou self-assigned this Aug 23, 2017
jackhorton pushed a commit to jackhorton/ApplicationInsights-node.js that referenced this issue Aug 24, 2017
OsvaldoRosado pushed a commit that referenced this issue Aug 25, 2017
* Updated diagnostic-channel, added subscribers for winston and pg

fixes #256

* Updated README.md
@lbochenek
Copy link

lbochenek commented Jan 24, 2018

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!

@larrywal
Copy link

larrywal commented Sep 3, 2020

Hi folks - I'm having this same issue following the instructions here: https://docs.microsoft.com/en-us/azure/azure-monitor/learn/nodejs-quick-start

Can someone advise? I have a Node app with both client and server. Each have a package.json.

I tried installing applicationinsights-js as well but still get the same issue above. Can someone help please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet