facundoolano / google-play-scraper

Node.js scraper to get data from Google Play
MIT License
2.34k stars 632 forks source link

Cannot import google-play-scraper #658

Closed EzequielAdrianM closed 1 year ago

EzequielAdrianM commented 1 year ago

npm install google-play-scraper

import gplay from "google-play-scraper";
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at internalCompileFunction (node:internal/vm:73:18)
    at wrapSafe (node:internal/modules/cjs/loader:1178:20)
    at Module._compile (node:internal/modules/cjs/loader:1220:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47

Node.js v18.17.1

Same error in Windows and in MacOS.

EzequielAdrianM commented 1 year ago

It was because I was calling the script "bot.js" and for some reason it now must be named under ".mjs" extension. Old Nodejs user, it happens.