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

[Bug]: importing alpaca-trade-api in react #234

Open
2 tasks done
Louvivien opened this issue Feb 23, 2023 · 2 comments
Open
2 tasks done

[Bug]: importing alpaca-trade-api in react #234

Louvivien opened this issue Feb 23, 2023 · 2 comments

Comments

@Louvivien
Copy link

Louvivien commented Feb 23, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

It is a create react app. I have installed alpaca-trade-api npm module and I try to import alpaca-trade-api in a React Component but 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?

Expected Behavior

No response

SDK Version I encountered this issue in

npm install --save @alpacahq/alpaca-trade-api

Steps To Reproduce

create react app
npm i @alpacahq/alpaca-trade-api
add this line to a react component: import Alpaca from '@alpacahq/alpaca-trade-api';

Filled out the Steps to Reproduce section?

  • I have entered valid steps to reproduce my issue or have attached a minimally reproducible case in code that shows my issue happening; and understand that without this my issue will be flagged as invalid and closed after 30 days.

Anything else?

No response

@Louvivien
Copy link
Author

I think it is for backend only

@304techmaven
Copy link

@Louvivien I can confirm that this package is designed for backend. I was able to setup a basic express server and then create calls that would import different parts of the alpaca npm package and use them to authenticate, make trades etc.

Once this backend is setup via express you can then use any front end angular/react/vue etc. to make calls to this backend to make trades or turn bots on/off via UI elements in that web app. Hope this adds great context for anyone in the future!

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

No branches or pull requests

2 participants