Home > Back-end >  Can't use 'redux' after long break with project
Can't use 'redux' after long break with project

Time:08-17

I have an React/Redux project which I left unattended for few months. After that, when restarting with npm start I receive errors:

Module '"redux"' has no exported member ___.
(and here there is one of: "combineReducers", "bindActionCreators", "AnyAction")

Besides, when I hover over redux in import statements it shows me a path to existing folder src/redux (with reducers etc) and not redux in node_modules. I have checked that redux folder in node_modules actually exists and its content looks like content in similar app.

I am sure I have not midified Webpack, I practically do not know how it works.

What I have done so far is I have uninstalled and installed again redux, but it has not helped (btw uninstalling has not removed redux from node modules). Has anybody an idea how to solve that?

Here is my ts.config

"compilerOptions": {
        "target": "es5",
        "lib": ["dom", "dom.iterable", "webworker", "esnext"],
        "allowJs": true,
        "skipLibCheck": true,
        "esModuleInterop": true,
        "allowSyntheticDefaultImports": true,
        "strict": true,
        "forceConsistentCasingInFileNames": true,
        "module": "esnext",
        "moduleResolution": "node",
        "resolveJsonModule": true,
        "isolatedModules": false,
        "noEmit": true,
        "jsx": "react-jsx",
        "noFallthroughCasesInSwitch": true,
        "baseUrl": "src",
        "paths": {
            "types/*": ["types/*"]
        }
    },
    "include": ["src"]
}

CodePudding user response:

Since you have a folder src/redux, it looks like your build tool (I suppose Webpack) is trying to import redux from this src/redux folder instead of node_modules/redux.

What you can try is either:

  • Name your folders in src such that they don't conflict with the package names you are using. In this case, maybe rename redux folder to something else e.g. src/reduxconfig, or
  • Fix your build tool's config file e.g. webpack.cofing or whatever config file you are using.

I personally prefer the first option. Typically, JavaScript bundlers usually first look for a module within the src folder, if they find it, they will not look for it in node_modules. If an import isn't found in src, the bundler will look for it in node_modules

  • Related