SyntaxError: Cannot use import statement outside a module
See original GitHub issueI tried this but i’m stumbled with this error
`$ node get-portfolio.js C:\Garage\Scripting\node\degiro-api_module\get-portfolio.js:1 import DeGiro, { DeGiroEnums, DeGiroTypes } from ‘degiro-api’ ^^^^^^
SyntaxError: Cannot use import statement outside a module ?[90m at wrapSafe (internal/modules/cjs/loader.js:1072:16)?[39m ` I installed it as described in your page and i see that it is installed in my setup
$ npm -g ls C:\Users\arso271062\AppData\Roaming\npm
– degiro-api@0.5.2
±- async@3.2.0
-- node-fetch@2.6.0
my get-portfolio.js contains the source from your site: `import DeGiro, { DeGiroEnums, DeGiroTypes } from ‘degiro-api’ const { PORTFOLIO_POSITIONS_TYPE_ENUM } = DeGiroEnums
(async () => {
const degiro: DeGiro = new DeGiro({ username: ‘my username’, pwd: ‘password’, })
await degiro.login()
const portfolio = await degiro.getPortfolio({ type: PORTFOLIO_POSITIONS_TYPE_ENUM.ALL }) console.log(JSON.stringify(portfolio, null, 2)) })()`
Please help me what i’m wrong. I’m from Perl bash background and the node enviroment is quite new for me. perhaps I’m using it wrong. I have the git bash for windows environment.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Thanks for the help. I had to install additionally @types/async and @types/node-fetch, I learned that i need to compile with
tsc foo.ts
and then run the compilednode foo.js
I hope it is that i can efficiently run it faster (suggest me if i’m wrong)
Great job !!, This is an awesome tool for my Degiro Trading. Million Thanks 😃
Great! 🥳🥳