mangocaptain mangocaptain - 9 months ago 73
Node.js Question

How does import work with node modules in referencing a module's exported name?

When a index.js does the below import, what is 'redux' referring to? I tried looking in the src directory of the redux package in the node_modules but couldn't find anything that exported 'redux'. Is this namespace just provided through the dependencies in the package.json file?

import { createStore } from 'redux'


It's refering to redux modules. CreateStore it's a part of the module. You should read the doc In es6 syntax you can use those templates

    import defaultMember from "module-name";
    import * as name from "module-name";
    import { member } from "module-name";
    import { member as alias } from "module-name";
    import { member1 , member2 } from "module-name";
    import { member1 , member2 as alias2 , [...] } from "module-name";
    import defaultMember, { member [ , [...] ] } from "module-name";
    import defaultMember, * as name from "module-name";
    import "module-name";