Getting error Unable to resolve module `os` after adding and importing yahoo-finance-data package

Hello, so when I try to import the npm package called “yahoo-finance-data” into my application, I’m getting this error, if I install the package but I don’t import it then I get no error:

Unable to resolve module `os` from `/Users/*/my-app/node_modules/yahoo-finance-data/node_modules/request-promise/lib/rp.js`: Module does not exist in the module map

This might be related to
To resolve try the following:
  1. Clear watchman watches: `watchman watch-del-all`.
  2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.
  3. Reset Metro Bundler cache: `rm -fr $TMPDIR/react-*` or `npm start -- --reset-cache`.


I’m importing it like this:

import YahooFinanceAPI from "yahoo-finance-data";

I already tried doing everything on the steps listed, already did around 10 different solutions found on Github, and restarted my computer but still no luck, the problem also happens when I try it on Snack ( do anybody have a solution?

Hey @jeronimocosio,

It looks like the yahoo-finance-data package isn’t built to be used within a react-native project because it has a dependency of request-promise that makes use of Node’s ‘os’ API that isn’t part of RN. From a quick search, it looks like there is a package someone built to expose the ‘os’ API in RN (react-native-os - npm) but there are two things of note here. 1) It requires you to run react-native link so you would have to detach your Expo project and use ExpoKit and 2) The last push was January of last year so it doesn’t seem to be well maintained.



1 Like

Thank you so much for this great answer! I think I will need to create my own package then. :slight_smile:

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.