Closed niyogi closed 7 months ago
do import gplay from "google-play-scraper";
Getting an error after npm installing this module and then using:
var gplay = require("google-play-scraper");
Around using import syntax. Any idea how to use this in CommonJS?
Hello, the error you're encountering is because the google-play-scraper package is an ES Module, and you're trying to import it using CommonJS syntax (require). As of recent updates in Node.js, there's a distinction between CommonJS and ES Modules, and they have different import mechanisms.
To resolve this issue, you'll need to use the import statement, which is the standard syntax for ES Modules. Here's how you can modify your script:
Change the file extension of your script from .js to .mjs. This explicitly tells Node.js that you're using ES Module syntax.
Replace the require statement with an import statement. like below:
import gplay from 'google-play-scraper';
# your code
Getting an error after npm installing this module and then using:
var gplay = require("google-play-scraper");
Around using import syntax. Any idea how to use this in CommonJS?