MonkeyBonkey MonkeyBonkey - 8 months ago 47
Node.js Question

Package.json dependcies issues in a react app using Walmart's Electrode framework

I'm getting started with Walmart's new React framework called Electrode.

However, I'm having trouble understanding where the project dependencies are defined since I don't see everything in package.json. I'm running a linter so it's showing me errors saying packages like redux and react are not defined in the dependencies. However, if I do an npm install, it does install all the packages. How does npm know to install the other packages?

Here's what's in the package.json - so the other packages like react must be linked or configured or defined elsewhere.

"dependencies": {
"above-the-fold-only-server-render": "^1.0.2",
"bluebird": "^3.4.6",
"electrode-archetype-react-app": "^1.0.0",
"electrode-csrf-jwt": "^1.0.0",
"electrode-react-ssr-caching": "^0.1.3",
"electrode-redux-router-engine": "^1.0.0",
"electrode-server": "^1.0.0",
"electrode-static-paths": "^1.0.0",
"lodash": "^4.10.1"

Answer Source

React and Redux are defined in electrode-react-ssr-caching's package.json, so they are indirectly dependencies of your project because you depend on electrode-react-ssr-caching.

You can see which package causes something to be installed with npm ls <package>, e.g. npm ls react, which will show the dependency tree for that package (see my answer on a similar question for an example). If you use Yarn, yarn why <package> will serve a similar purpose.