When running npm install
, the dev dependencies are usually also get installed. However today, we have a build runs inside a docker container which requires a test result to be generated and we cannot get test run. Turns out the Karma
packages in the dev dependencies are not installed.
The reason is the container in which npm is run has a NODE_ENV
environment var set to production
so npm will pick that up and skip the dev dependencies installation.
Other scenarios dev will not be installed is
1. the npm config production value is set to true. use below command to check.
npm config get production
2. npm is run with --production
flag.
So to solve this, we just unset that var and set it back after npm install.
unset NODE_ENV npm install export NODE_ENV=production
Advertisements