Importing Redux on Repl.it causing import error

I am trying to import Redux code to use on Repl.it:

https://replit.com/@Michael_Nicol/Manage-Boxes-Redux-Code

Whenever I try to import createStore from redux, I get a error:

SyntaxError: Cannot use import statement outside a module

I tried adding "type": "module" to the package.json, but I get an error.

Error [ERR_REQUIRE_ESM]: require() of ES Module /home/runner/Manage-Boxes-Redux-Code/index.js not supported.
Instead change the require of index.js in null to a dynamic import() which is available in all CommonJS modules.

{
  "name": "manage",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "type": "module",
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "redux": "^4.1.2"
  }
}

Try common.js syntax:

const createStore = require('redux').createStore;

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.