Problem with: const ccxt = require('ccxt');
See original GitHub issue- OS: Windows 10
- Programming Language version: Visual Studio 2017 (Universal Windows Javascript App)
- CCXT version: #465
- Exchange: Bitfinex
- Node.js 11.9.0 installed
- Method: const ccxt = require(‘ccxt’);
Hello!
I succeed to return all exchanges in chrome console with below code: console.log(ccxt.exchanges);
But I think that I don’t want to run the library in a browser. But instead in Visual Studio Debugger. Now comes the problem. When I run it in the debugger instead and NOT in a browser, I receive below commented error.
So const ccxt = require(‘ccxt’); seems to have a problem here because ‘require’ is not defined somehow. I don’t know how to implement this correctly? Please see more comments in the code snippets below. _(In the 3rd codesnippet with the ‘CORS’ error is the reason I want to Not run it in a browser but Visual Studio directly because as I understood it this can then be avoided?)
//const Exchange = require('./js/base/Exchange')
//Unhandled exception at line 33, column 1 in ms - appx://6b49fdc7-ae95-44f8-9223-0bfbb5025163/ccxt-master/ccxt.js
//0x800a1391 - JavaScript runtime error: 'require' is not defined
const ccxt = require('ccxt');
COMPLETE CODE WITH COMMENTS ABOVE EACH TO UNDERSTAND WHAT I HAVE TRIED `<body onload="myFunction();"> <script src="ccxt-master/ccxt.js"></script> <script src="js/require.js"></script> <script type="text/javascript" src="https://unpkg.com/ccxt"></script> <script type="text/javascript"> function myFunction() {
//This code returns this error when NOT running in a browser (But running in Visual Studio directly)
//const Exchange = require('./js/base/Exchange')
//Unhandled exception at line 33, column 1 in ms - appx://6b49fdc7-ae95-44f8-9223-0bfbb5025163/ccxt-master/ccxt.js
//0x800a1391 - JavaScript runtime error: 'require' is not defined
const ccxt = require('ccxt');
/*-------------------------------------------------------------*/
//This code returns all exchanges in chrome console
console.log(ccxt.exchanges);
/*-------------------------------------------------------------*/
//This code returns this error in chrome console
//Access to fetch at 'https://api.bitfinex.com/v1/symbols_details' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin'
//header is present on the requested resource.If an opaque response serves your needs, set the request's mode to 'no - cors'
//to fetch the resource with CORS disabled.
let exchange = new ccxt.bitfinex();
exchange.verbose = true;
console.log(exchange.loadMarkets());
}
</script>
</body>`
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Thank you kroitor, that was a big help. Then I know where to start so I am in the correct environment with all javascript etc.
Yes, basically, you should search for “how to start programming with Node.js” tutorials. The link you posted should help. However, I’d also recommend these: