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

I am facing 'Error: Unable to resolve module os' in this file node_modules/@opentelemetry/resources/build/src/detectors/platform/node/HostDetectorSync.js #5240

Open
Moonubanna opened this issue Dec 7, 2024 · 2 comments
Labels
question User is asking a question not related to a new feature or bug runtime:hermes Unsupported Runtime Hermes

Comments

@Moonubanna
Copy link

Moonubanna commented Dec 7, 2024

Hello Everyone,

I am facing this below error, I am using this library in my RN project i think there are some code which is trying to use the Node.js os module, which is not available in the React Native environment. React Native doesn't support Node.js core modules like os, fs, etc. Is there newer or older version of OpenTelemetry that offers better React Native support.

error: Error: Unable to resolve module os from /Users/praveen36singhq/Desktop/demoCoach/TodoListMobile/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/HostDetectorSync.js: os could not be found within the project or in these directories:
node_modules

dependencies:
"@opentelemetry/api": "^1.9.0",
"@opentelemetry/exporter-metrics-otlp-http": "^0.55.0",
"@opentelemetry/exporter-trace-otlp-http": "^0.55.0",
"@opentelemetry/resources": "^1.28.0",
"@opentelemetry/sdk-metrics-base": "^0.31.0",
"@opentelemetry/sdk-trace-base": "^1.28.0",
"@opentelemetry/sdk-trace-web": "^1.28.0",
"react": "17.0.1",
"react-native": "0.64.2",
"react-native-get-random-values": "^1.11.0"

@pichlermarc
Copy link
Member

Hi @Moonubanna - could you provide some info on how you are you importing this?
From what I can tell, the metro.config.js should default to resolving whatever is specified in the "browser" field of a package, so I'd assume that this should work fine for resource detectors and you should get a no-op detector instead of the Node.js one.

Are you able to share your metro.config.js?

Also - please note that React Native is not officially supported by this project.

@pichlermarc pichlermarc added question User is asking a question not related to a new feature or bug runtime:hermes Unsupported Runtime Hermes labels Dec 12, 2024
@pichlermarc
Copy link
Member

@Moonubanna friendly ping

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question User is asking a question not related to a new feature or bug runtime:hermes Unsupported Runtime Hermes
Projects
None yet
Development

No branches or pull requests

2 participants