AmyrAhmady/steamdb-js

SyntaxError: Cannot use import statement outside a module

MonsieurBibo opened this issue · 2 comments

Hey, I get an error when I try your example:
PS C:\Users\selim\Desktop\Développement\TEST> node .\index.js (node:10932) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension. (Use node --trace-warnings ...` to show where the warning was created)
C:\Users\selim\Desktop\Développement\TEST\index.js:1
import { Game } from "steamdb-js";
^^^^^^

SyntaxError: Cannot use import statement outside a module
at wrapSafe (internal/modules/cjs/loader.js:1116:16)
at Module._compile (internal/modules/cjs/loader.js:1164:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
at Module.load (internal/modules/cjs/loader.js:1049:32)
at Function.Module._load (internal/modules/cjs/loader.js:937:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47`

Hi, sorry for my very late answer.
here's my response on stackoverflow: https://stackoverflow.com/a/62974060/12097179

Been a while since this issue was created and I sadly didn't get any notification, I'm sorry!.

first of all, example and steamdb-js code is using ES5 standards (such as import and export syntax)
You need to enable those first, you can use latest available Nodejs versions, or use a transpiler; If you are not using Node +v13 or don't know how to do that, here's my recommendation:

Now everything should work fine and steamdb-js should be able to be """execute"""

I'm putting stress on execute cause there's an issue now, we know steamdb is using CloudFlare, they have "Under Attack" mode enabled and that's an issue that can be bypassed, but the sad part is due to CloudFlare's new changes, I doubt current libraries out there work at the moment, I'll update my library as soon as I find a way.

Thanks!

Thanks!