It is a create react app. I have installed alpaca-trade-api npm module
npm install --save @alpacahq/alpaca-trade-api
and I try to import alpaca-trade-api in a React Component but when I add this line
import Alpaca from ‘@alpacahq/alpaca-trade-api’;
I get this error :
Compiled with problems:X
ERROR in ./node_modules/@alpacahq/alpaca-trade-api/node_modules/dotenv/lib/main.js 24:11-24
Module not found: Error: Can’t resolve ‘fs’ in ‘/Users/vivien/Documents/stock-trading-simulator/client/node_modules/@alpacahq/alpaca-trade-api/node_modules/dotenv/lib’
ERROR in ./node_modules/@alpacahq/alpaca-trade-api/node_modules/dotenv/lib/main.js 26:13-28
Module not found: Error: Can’t resolve ‘path’ in ‘/Users/vivien/Documents/stock-trading-simulator/client/node_modules/@alpacahq/alpaca-trade-api/node_modules/dotenv/lib’
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.If you want to include a polyfill, you need to:
- add a fallback ‘resolve.fallback: { “path”: require.resolve(“path-browserify”) }’
- install ‘path-browserify’
If you don’t want to include a polyfill, you can use an empty module like this:
resolve.fallback: { “path”: false }ERROR in ./node_modules/urljoin/index.js 20:11-26
Module not found: Error: Can’t resolve ‘path’ in ‘/Users/vivien/Documents/stock-trading-simulator/client/node_modules/urljoin’
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.If you want to include a polyfill, you need to:
- add a fallback ‘resolve.fallback: { “path”: require.resolve(“path-browserify”) }’
- install ‘path-browserify’
If you don’t want to include a polyfill, you can use an empty module like this:
resolve.fallback: { “path”: false }
Do you know why?