Missing npm dependency

I have "react": "15.4.0" in my package.json.

Local npm install outputs:

+-- react@15.4.0
| +-- fbjs@0.8.6
| | +-- core-js@1.2.7
| | +-- isomorphic-fetch@2.2.1
| | | +-- node-fetch@1.6.3
| | | | `-- encoding@0.1.12
| | | |   `-- iconv-lite@0.4.15
| | | `-- whatwg-fetch@2.0.1
| | +-- promise@7.1.1
| | | `-- asap@2.0.5
| | `-- ua-parser-js@0.7.12
| `-- loose-envify@1.3.0

CircleCI npm install outputs:

react@15.4.0 node_modules/react
├── object-assign@4.1.0
├── loose-envify@1.3.0 (js-tokens@2.0.0)
└── fbjs@0.8.6 (ua-parser-js@0.7.12, promise@7.1.1, isomorphic-fetch@2.2.1, core-js@1.2.7)

In my code I import keyMirror from "fbjs/lib/keyMirror"; and everything works as expected locally.

However when installing on CircleCI, my webpack build fails with the following error:

ERROR in ./src/js/actions.js
Module not found: Error: Cannot resolve module 'fbjs/lib/keyMirror' in /home/ubuntu/alex_web/src/js
 @ ./src/js/actions.js 7:17-46

Logging into the environment via ssh I can see there is no fbjs folder under node_modules (in my local environment the node_modules\fbjs folder is there).

Why is the sub-dependency being installed locally but not on CircleCI?

1 Like