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

Error: Cannot find module './Instrumentation.js' when running frontend service for local development #407

Closed
kodayashi opened this issue Oct 6, 2022 · 10 comments · Fixed by #434
Labels
bug Something isn't working

Comments

@kodayashi
Copy link

kodayashi commented Oct 6, 2022

Bug Report

Which version of the demo you are using?

main (latest)

Symptom

I'm trying to follow the README for running the frontend service locally. After running

docker compose run --service-ports -e NODE_ENV=development --volume $(pwd)/src/frontend:/app --volume $(pwd)/pb:/app/pb frontend sh

I get this error:

Error: Cannot find module './Instrumentation.js'
Require stack:

  • internal/preload
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
    at Function.Module._load (node:internal/modules/cjs/loader:804:27)
    at Module.require (node:internal/modules/cjs/loader:1028:19)
    at Module._preloadModules (node:internal/modules/cjs/loader:1303:12)
    at loadPreloadModules (node:internal/bootstrap/pre_execution:583:5)
    at prepareMainThreadExecution (node:internal/bootstrap/pre_execution:95:3)
    at node:internal/main/run_main_module:7:1 {
    code: 'MODULE_NOT_FOUND',
    requireStack: [ 'internal/preload' ]
    }

It looks like npm start is being run (per package.json) as opposed to npm dev. Am I doing something wrong here?

Reproduce

Just follow the instructions for running the frontend service locally in the README file.

@kodayashi kodayashi added the bug Something isn't working label Oct 6, 2022
@julianocosta89
Copy link
Member

Are you running the command from the root folder of the project?
I mean not in the src/frontend folder.

@kodayashi
Copy link
Author

@julianocosta89 - Correct, I'm running it from the root folder.

@julianocosta89
Copy link
Member

Cool, just to be sure.
I'll try to reproduce.
Thanks for reporting it!

@julianocosta89
Copy link
Member

I'm on the road ATM, I will take a look later.
Maybe @xoscar has an idea of what may be the root cause of that.

@kodayashi
Copy link
Author

Thanks @julianocosta89. @xoscar all I can tell at this point is that npm is being run in production mode as opposed to dev. In package.json, there's the requirement for ./Instrumentation.js in "start" (which is referenced in the error above)

"start": "node --require ./Instrumentation.js server.js"

Whereas "dev" in package.json is what we're looking to run from what I can tell as it has the correct relative path to Instrumentation.js:

"dev": "npm run grpc:generate && NODE_OPTIONS='-r ./utils/telemetry/Instrumentation.js' next dev"

So, I think the answer lies in understanding why start is firing off instead of dev when running "docker compose run..." command in the frontend README file.

@xoscar
Copy link
Contributor

xoscar commented Oct 7, 2022

Oh I think it's because a change was made to move away from CMD in the frontend docker file to use ENTRYPOINT instead. And the problem with that is that it doesn't allow for command overwrite in this case when running the container it will always run npm start @julianocosta89 changes https://github.com/open-telemetry/opentelemetry-demo/pull/342/files

@julianocosta89
Copy link
Member

Also, @puckpuck do you see any issue if we return the frontend to CMD instead of ENTRYPOINT.
I've tested locally and changing it back to CMDsolves the issue.

@puckpuck
Copy link
Contributor

The only issue I see is consistency with the other services, which all use ENTRYPOINT

@julianocosta89
Copy link
Member

@puckpuck if consistency is the only issue, I'll go ahead and send a PR to use CMD as this solves the issue.

@julianocosta89
Copy link
Member

Hello all, I've just sent a PR fixing this :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants